-
Notifications
You must be signed in to change notification settings - Fork 33
Time handling with moment timezone
Megan Riel-Mehan edited this page Oct 23, 2019
·
3 revisions
- Convert local time to timestamp with offset
th.dateObj is a unix timestamp in milliseconds
tzString is a zone string like 'America/New_York'
moment(th.dateObj).tz(tzString).format()
// example output: 2019-10-07T17:30:00-04:00- Convert to local time if you know the zone name
event.zoneName = 'America/New_York'
moment(event.timeStart).tz(event.zoneName).format('MMMM Do YYYY, h:mm a z')- Convert to local time from date time stamp with offset but no timezone name. Note: without location information you can't get the actual time zone out because of daylight savings.
moment.parseZone(record.timeStart).format('ddd, MMM D YYYY h:mm a');