Home > Back-end >  How to Convert date in string type to another date format. | Flutter | Dart
How to Convert date in string type to another date format. | Flutter | Dart

Time:12-02

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.

CodePudding user response:

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));
}

CodePudding user response:

Try below code hope its help to you.Used intl package enter image description here

  • Related