0

Here is the date/time string I am passing into MomentJS

let value = '2018-07-21T17:09:51.000Z'

This should be 07/21/2018 @ 5:09:51 PM

moment(value).format("dddd, MMMM Do YYYY, h:mm:ss a")

Moment returns: Saturday, July 21st 2018, 10:09:51 am

Why is it showing 10:09:51 am and not 5:09:51 PM ?

Thanks

jremi
  • 2,879
  • 3
  • 26
  • 33
  • 1
    Set the correct timezone, see https://stackoverflow.com/questions/15347589/moment-js-format-date-in-a-specific-timezone – jshamble Jul 22 '18 at 01:37

1 Answers1

0

Simple answer... as @jshamble indicated... make sure you are using the timzone method .utc()

Solution to my question in the example:

moment(value).utc().format("dddd, MMMM Do YYYY, h:mm:ss a")
jremi
  • 2,879
  • 3
  • 26
  • 33