Issue
I want to remove the time format from this date in a flutter,
I want to show a date like this 22-10-2019
or 2019-10-22
2019-10-22 00:00:00.000
Solution
Please try below code:-
First you can create below method:-
String convertDateTimeDisplay(String date) {
final DateFormat displayFormater = DateFormat('yyyy-MM-dd HH:mm:ss.SSS');
final DateFormat serverFormater = DateFormat('dd-MM-yyyy');
final DateTime displayDate = displayFormater.parse(date);
final String formatted = serverFormater.format(displayDate);
return formatted;
}
Second you can call above method like below code:-
String yourDate = '2019-10-22 00:00:00.000';
convertDateTimeDisplay(yourDate);
Answered By – Dhaval Patel
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0