How to Convert date in string type to another date format. | Flutter | Dart


I have a string date and I want to convert it in another format. For eg : I have a date "25/04/2020" as string and I want to convert this to the string as "25 Apr 2020" like this.
"10/02/2020" become "10 Feb 2020",
"27/11/2021" become "27 Nov 2021", like this.


Use package intl

import 'package:intl/intl.dart';

void main() {
  var dateString = "25/04/2020";
  var dateTime = DateFormat('dd/MM/yyyy').parse(dateString);
  print(DateFormat('dd MMM yyyy').format(dateTime));

Answered By – Alan haha

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *