timeago.dart icon indicating copy to clipboard operation
timeago.dart copied to clipboard

Invalid date format: eg: 2020-1-6 15:3:8

Open thanhansoft opened this issue 5 years ago • 1 comments

Hi admin,

I try string 2020-1-6 15:3:8 convert error: timeago.format(DateTime.parse(2020-1-6 15: 3: 8)) => Error If I use: timeago.format(DateTime.parse(2020-01-06 15: 03:08)), that's fine Please help me fix it.

thanhansoft avatar Jan 07 '20 15:01 thanhansoft

You can't use this string(2020-1-6 15: 3: 8). It not accepted string for DateTime.prase () method. Therefore it trows FormatException.

Examples of accepted strings:

  • "2012-02-27 13:27:00"
  • "2012-02-27 13:27:00.123456789z"
  • "2012-02-27 13:27:00,123456789z"
  • "20120227 13:27:00"
  • "20120227T132700"
  • "20120227"
  • "+20120227"
  • "2012-02-27T14Z"
  • "2012-02-27T14+00:00"
  • "-123450101 00:00:00 Z" : in the year -12345.
  • "2002-02-27T14:00:00-0500": Same as "2002-02-27T19:00:00Z" `

Reference: https://api.dart.dev/stable/2.7.0/dart-core/DateTime/parse.html

ShalikaAshan01 avatar Jan 15 '20 16:01 ShalikaAshan01