0

I've been trying convert a String to DateTime in dart using DateTime.parse(dateStart), where 'dateStart' is my variable that I use to get the date, for example in the next format '24/12/2022', but I catch invalid date format, I would like to known which are the validates formats to use in dart.

 DateTime.parse(dateStart)

2 Answers2

0

You can format '24/12/2022' to DateTime like this:

final dateTime = DateFormat('dd/MM/yyyy').parse('24/12/2022');
manhtuan21
  • 2,388
  • 2
  • 10
  • 24
0

You need to use intl package to parse string date to datetime object. Please check sample Datetime parse example as below.

DateTime tempDate = new DateFormat("dd/MM/yyyy").parse(savedDateString);
ABV
  • 857
  • 2
  • 3