# membuat Date time lokal

Cara membuat date time lokal hape



import intl.dart



```
import 'package:intl/intl.dart';
import 'package:intl/date_symbol_data_local.dart';
```

lalu

```dart
String tanggal = '';
  @override
  void initState() {
    super.initState();
    initializeDateFormatting();
  }
```

lalu&#x20;

```dart
DateFormat.yMMMMEEEEd('id').format(DateTime.parse(tanggal))
```

via extention

```dart
import 'package:intl/intl.dart';
import 'package:intl/date_symbol_data_local.dart';



extension toLokalTime on DateTime {
  String toLokal() {
    initializeDateFormatting();
    try {
      return new DateFormat.yMMMMEEEEd ('id').add_jm() .format(this);
    } catch (e) {
      return null;
    }
  }
}
```

penggunaan



```dart
Text(DateTime.now().toLokal().toString()),
```


