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

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

lalu

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

via extention

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

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

Last updated