APIs & Integrations

alansp
Participante

Major (?) issue with timezone on stored dates

resolver

Our timezone is set to PST (-7), but when we select 2019-03-28 in a datepicker, it stores it as 2019-03-28 00:00 UTC.

 

The problem here is that when we extract that date via API, and convert to PST, it becomes:

 

2019-03-27 17:00 PST

 

The day has completely changed.

 

Surely if we've selected PST as the timezone for our account, the date should be stored as 2019-03-28 00:00 PST, ie: 2019-03-28 07:00 UTC

1 Soluciones aceptada
JasminLin
Solución
HubSpot Employee
HubSpot Employee

Major (?) issue with timezone on stored dates

resolver

Hey @alansp , sorry I should have included the option that you could also direct message me your hub details. But no worries, I do have access to the support ticket you have open with one of our support rep and I worked with her on your query.

 

The reporting_date deal property you are using is a date type property - you can see the type by using this endpoint. Any date picker property created in HubSpot is created as a date property. The way date properties work currently is that it only stores the date and not the time. So by default it is set to midnight UTC. You can only store timestamps that are exactly midnight UTC e.g. 1556841600000 is 3 May 2019 00:00:00 UTC. It is not possible to store a timestamp that is not exactly midnight UTC e.g. if you try via API to store 1556895600000 which is 3 May 2019 15:00:00 UTC there will be an error. So what you are seeing is currently expected. 

 

A workaround for this is to use datetime properties instead. Datetime properties can only be created via API (e.g. create deal property API) and with this you can store any timestamps that is based on your preferred timezone. 

 

You can read more about this behavior here https://developers.hubspot.com/docs/faq/how-should-timestamps-be-formatted-for-hubspots-apis 

Ver la solución en mensaje original publicado

3 Respuestas 3
JasminLin
HubSpot Employee
HubSpot Employee

Major (?) issue with timezone on stored dates

resolver

Hey @alansp , could you provide me your hub ID and an example of where you are setting the date and pulling it via API? E.g. a contact record's date property? 

0 Me gusta
alansp
Participante

Major (?) issue with timezone on stored dates

resolver

Hi @JasminLin 

 

I'd prefer not to post account data here, sorry.

 

Are you able to access support tickets? I've detailed everything in ticket 2404161, including a deal ID (and field) for the example I gave above.

0 Me gusta
JasminLin
Solución
HubSpot Employee
HubSpot Employee

Major (?) issue with timezone on stored dates

resolver

Hey @alansp , sorry I should have included the option that you could also direct message me your hub details. But no worries, I do have access to the support ticket you have open with one of our support rep and I worked with her on your query.

 

The reporting_date deal property you are using is a date type property - you can see the type by using this endpoint. Any date picker property created in HubSpot is created as a date property. The way date properties work currently is that it only stores the date and not the time. So by default it is set to midnight UTC. You can only store timestamps that are exactly midnight UTC e.g. 1556841600000 is 3 May 2019 00:00:00 UTC. It is not possible to store a timestamp that is not exactly midnight UTC e.g. if you try via API to store 1556895600000 which is 3 May 2019 15:00:00 UTC there will be an error. So what you are seeing is currently expected. 

 

A workaround for this is to use datetime properties instead. Datetime properties can only be created via API (e.g. create deal property API) and with this you can store any timestamps that is based on your preferred timezone. 

 

You can read more about this behavior here https://developers.hubspot.com/docs/faq/how-should-timestamps-be-formatted-for-hubspots-apis