The easiest way to achieve this is by installing intl. google intl and find it in pub.dev follow the installation instruction and add it to pubspec.yml

 

import it 

import 'package:intl/intl.dart';

 

 

use it in the following syntax: 

 Text(
     DateFormat.yMMMMd().format(tx.date),
     style: TextStyle(fontWeight: FontWeight.w400, color: Colors.grey) ),

 

You have to open the class DateFormat()and then call the format method from that class. in the example above tx.date is of type DateTime from dart.

 

 

 

 

 

DateFormat Patterns

The intl package supports a broad range of date formatting patterns. Here's a list (taken from the official docs):

 
  1. Pattern Result
  2. ---------------- -------
  3. new DateFormat.yMd() -> 7/10/1996
  4. new DateFormat("yMd") -> 7/10/1996
  5. new DateFormat.yMMMMd("en_US") -> July 10, 1996
  6. new DateFormat.jm() -> 5:08 PM
  7. new DateFormat.yMd().add_jm() -> 7/10/1996 5:08 PM
  8. new DateFormat.Hm() -> 17:08 // force 24 hour time