问题
I have a date string from an API containing a timezone using abbreviations:
"01/16/2018 12:15pm PST"
Moment.js seems to ignore the timezone though, even if I use the z
timezone input parsing string. That only seems to handle timezones strings that are time offsets like -10:00
For example, I would expect these two commands to return different values, because they have different timezone strings ('PST' and 'UTC')
moment('01/01/1990 02:03pm PST', 'MM/DD/YYYY hh:mma z').format('h:mm A')
moment('01/01/1990 02:03pm UTC', 'MM/DD/YYYY hh:mma z').format('h:mm A')
But they both return "2:03 PM"
I'm also using moment-timezone
, as in import moment from 'moment-timezone';
, but this does not seem to add the parsing functionality for timezone strings.
来源:https://stackoverflow.com/questions/48658068/moment-js-how-to-parse-a-date-string-string-with-a-text-timezone-like-pst