I am using dart/flutter and need some help on how format date . How do I parse the following string to a timestamp
2019-08-22T00:40:57.166+0000
Basically, I want to get the timestamp for the above date and pass it to timeago to format
Thanks
I am using dart/flutter and need some help on how format date . How do I parse the following string to a timestamp
2019-08-22T00:40:57.166+0000
Basically, I want to get the timestamp for the above date and pass it to timeago to format
Thanks
This code will take your string and convert it to milliseconds since epoch (I assume that's what you mean by timestamp:
String dateStr = '2019-08-22T00:40:57.166+0000';
DateTime date = DateTime.parse(dateStr);
print("The timestamp for date '$dateStr' is ${date.millisecondsSinceEpoch}");
The output of the above program is:
The timestamp for date '2019-08-22T00:40:57.166+0000' is 1566434457166
Good luck! :)