JavaScript won't parse GMT Date/Time Format

后端 未结 6 2159
我在风中等你
我在风中等你 2021-01-22 06:33

I\'m trying to get JavaScript to parse a date and time format for me, with the eventual aim of telling me the days passed since that date and the time right now (locally).

6条回答
  •  野性不改
    2021-01-22 07:33

    That's an ISO 9601 date -- they're a nice standard to work with. Try just munging it using regular expressions:

    (\d{4})-(\d{2})-(\d{2})[ tT](.*)
    

    to

    \2/\3/\1 \4
    

提交回复
热议问题