Date time string: '2021-12-12T11:11:00' i want to remove 'T11:11:00' from that whole string.
After removing, my string should be: '2021-12-12'
Any idea? Please help me.
CodePudding user response:
import 'package:intl/intl.dart'; //note --->>> import package
DateTime parsedDateTime = DateTime.parse('2021-12-12T11:11:00');
String formatDate = DateFormat("yyyy-MM-dd").format(parsedDateTime);
OUTPUT ->
2021-12-12
CodePudding user response:
String _date_and_time = "2021-12-12T11:11:00";
String date = _date_and_time.split("T")[0];
print("Date is : ${date}");