Moment.js - Converting UTC To Eastern Time

The way I figured this out was to do:

var now = ((moment(Date.now()).utcOffset('-0500').format('x'));
//Parse it into native JS object: 
now = new Date(parseInt(now));

I want to point something out though that I hope will save someone the days of time this burdened me for. My main issue was that Amazon Lambda was providing time in UTC, no matter what I was doing. The fix for this issue was to simply set the Node TZ environment variable:

process.env.TZ = 'America/New_York';

First, install moment timezone and install all of the timezones by using timezone-with-data.js or specifically only load the timezones you need

If you have a date that you know is in UTC and want to convert it to Eastern time, use the moment.utc() function to actually parse the UTC datestring. Then when you call .tz() on it will properly convert:

moment.utc(date_string).tz("America/New_York")

If you simply do moment(date_string).tz("America/New_York") the time gets parsed in your local timezone by default, and it will not adjust the date.


Eastern Standard Time (EST) is 5 hours behind Coordinated Universal Time (UTC).

With moment.js, you can subtract 5 hours from UTC timezone.

moment.utc().subtract(5, 'hours').format("YYYY-MM-DD HH:mm:ss.SSS")

Or

If you are willing to add another library like moment-timezone. You can just use:

moment().tz("America/New_York").format("YYYY-MM-DD HH:mm:ss.SSS")