Skip to main content
Question

Why does Zapier my datetime string to UTC?

  • October 26, 2021
  • 5 replies
  • 626 views

Forum|alt.badge.img

When I normally run (e.g. in a browser console)

var date = new Date('2021-10-25T08:06:08-07:00')

the timezone is kept. However, in Zapier, when I do the same thing, it strips the timezone information and shows “2021-10-25T15:06:08.000Z”.  I need to know the hours in the original timezone. I’ve checked the profile settings and zap settings, and both are set to Los Angeles.

Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

5 replies

Troy Tessalone
Forum|alt.badge.img+14

Hi @djung 

Try treating the timestamp as a string instead of as a Date.


Forum|alt.badge.img
  • Author
  • Beginner
  • 12 replies
  • October 27, 2021

@Troy Tessalone So you mean extracting the hour myself? That’s an alternative for sure. I was wondering if someone knew of this issue on Zapier’s end too though and whether it’s intended to be fixed.


Troy Tessalone
Forum|alt.badge.img+14

@djung 

You can try using the Formatter > Date & Time > Format step: https://zapier.com/help/create/format/modify-date-and-time-formats-in-zaps

 

I don’t think there’s anything wrong with the Code step behavior.

It’s treating the new Date in UTC time.

You’d have to use additional JavaScript to set the time zone: https://www.w3schools.com/jsref/jsref_tolocalestring.asp

Moment.js can help with this: https://momentjs.com/timezone/

 

 


Forum|alt.badge.img
  • Author
  • Beginner
  • 12 replies
  • October 27, 2021

But the timezone is in the timestamp string. I’m wondering why Zapier’s javascript doesn’t behave the same way as javascript in a web browser, which would see the timezone and retain that information when calling `new Date()` on the timestamp.

 

I don’t think Moment.js can be used in Zapier, can it?


Troy Tessalone
Forum|alt.badge.img+14

@djung 

Based on your screenshots it’s converting to UTC.

Notice the hour is originally 08 with a 7 hour time zone offset.

Then, with the Zap Code step with JavaScript, it’s converted to UTC as “2021-10-25T15:06:08.000Z”.

Notice the hour is now 15 and there is no time zone offset.

 

Underneath the Code editor there is this.

Warning! This is an advanced action! Uses Node 10.x.x. Please read the Code documentation for more information.

 

You can open a ticket with Zapier Support for further clarification: https://zapier.com/app/get-help