Search code examples
datetimeflutterstring-to-datetime

How to convert the specific String to DateTime Format in flutter


String date  = 'July 7,2020 10:00 AM'

How can I convert the above string to DateTime Format?


Solution

  • String date = 'July 7,2020 10:00 AM';
    DateFormat d = DateFormat('MMMM d,yyyy hh:mm a');
    print(d.parse(date));
    

    For more info : https://api.flutter.dev/flutter/intl/DateFormat-class.html