-1

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.

Ravindra S. Patil
  • 11,757
  • 3
  • 13
  • 40

2 Answers2

3

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));
}
Alan haha
  • 491
  • 1
  • 4
  • 10
0

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

DateTime now = DateTime.now();
String formattedDate = DateFormat('dd MMM yyyy ').format(now);
print(formattedDate);

Your Widget:

             Text(
                formattedDate,
              ),

Your result screen-> enter image description here

Ravindra S. Patil
  • 11,757
  • 3
  • 13
  • 40