Forum Discussion
You can use Date.now().toLocaleDateTimeString(’ { “timeZone”:“EST” , " format" :" YYYY-MM-DD" }')
- shane6 years agoNew Contributor II
That will give you a date-time string but not a timestamp. Try to create a timestamp from that and that is my issue.
- stevegoodwin6 years agoEmployee
if you want to adjust a GMT timestamp to PST (-7), what about:
Date.now().getTime() + (3600 * -7)
or
Date.parse(Date.now().plusHours(-7)).getTime()- shane6 years agoNew Contributor II
Unfortunately that isn’t how timezones work though.
I would have to calculate the offset based on the America/Las_Angeles timezone at the given DateTime.Specific example, I need to generate the timestamp for the following date to pass into an API: “2019-09-21 00:00:00” but I need to write a bunch of logic to determine whether that time in the America\Las_Angeles timezone would be PDT or PST (as daylight savings time may or may not be in effect, which effects the offset). This should be simple if I could create the Date object in a timezone other than UTC but I can’t find a way to do so.
The API I haver to hit is set to PST in it’s handling of the passed in timestamp. It only returns data from the provided timestamp until end of that day. If I pass in a UTC based timestamp then the results will be way off, and I am needing a full day of data which means passing in a PST based timestamp for the 00:00:00 time of a given date (which I can’t generate in SnapLogic).
- shane6 years agoNew Contributor II
as was gone over above, this doesn’t work