Home > Mobile >  Flutter: Formatting DateTime in flutter
Flutter: Formatting DateTime in flutter

Time:05-21

How to format flutter DateTime as 10th Oct 2020

tried

String date = DateFormat("dd, mm, y").format (date.utc());//10 October 2020

CodePudding user response:

you can use the Jiffy package from here ==> https://pub.dev/packages/jiffy.

this is an example of formatting DateTime:

import 'package:jiffy/jiffy.dart';

void main() {
  DateTime currentTime = DateTime.now();


  String result = Jiffy(currentTime).format('MMM do yy');
  print(result);

}

CodePudding user response:

Try out this package, Jiffy Just simply add the do date pattern. See below

Jiffy([2020, 10, 10]).format("do MMM yyyy"); //10th Oct 2020

You can also add your DateTime object

Jiffy(DateTime(2020, 10, 10)).format("do MMM yyyy"); //10th Oct 2020
  • Related