Question

Why does Zapier my datetime string to UTC?

  • 27 October 2021
  • 5 replies
  • 442 views

Badge

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.


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

Userlevel 7
Badge +14

Hi @djung 

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

Badge

@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.

Userlevel 7
Badge +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/

 

 

Badge

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?

Userlevel 7
Badge +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