I have a string in this format.
var stringDate = '27-04-2021 19:45' //dd-MM-yyyy HH:mm
I want to convert this String date to Timestamp (millisecondsSinceEpoch)
import 'package:intl/intl.dart';
getCustomFormattedDateTime(String givenDateTime, String dateFormat) {
// dateFormat = 'MM/dd/yy';
final DateTime docDateTime = DateTime.parse(givenDateTime);
return DateFormat(dateFormat).format(docDateTime);
}
You can use this method
getCustomFormattedDateTime('2021-02-15T18:42:49.608466Z', 'MM/dd/yy');
Result:
02/15/21