1

I have a scheduled field in MongoDB that is date time, an example being:

"scheduled" : ISODate("2019-09-17T09:00:00Z")

I'm in the Eastern Time Zone, and so are all my clients. What on earth do I need to do to get times to display and update using EST?

I try displaying the date by itself, without moment.js, and it displays as 9/17/19, 5:00 AM, but the appointment time is actually at 9AM.

When I used moment-timezone, it still displayed as 5AM.

The only way I can get it to display correctly is doing this(which I do not understand, since I'd have thought -4 or something like that would work but it doesn't):

const scheduledtime = moment(scheduled)
              .utcOffset(0)
              .format('MM/DD/YY hh:mm a');

When I try to use scheduledtime = moment(scheduled).tz('America/New_York').format('MM/DD/YY hh:mm a'); it shows as 5AM. If I use scheduledtime = moment(scheduled).tz('America/New_York').format('z'); I get a pipe error.

Can someone please help me understand what I need to do to make this work? I just don't get what's happening, and how to either save the dates correctly so they display without adjustment OR how to display them appropriately.

4

0 回答 0