APIs & Integrations

jmci
Member

Forms API Date Property

Hello,

I'm having some trouble with the Forms API. I am sending an API request to HubSpot after a customer completes a form on our website. Along with the API request, I'm sending a date value that is being stored on the contact record. That property already exists on the contact record and in the past, the date was being populated via the API as expected. Recently (mid-June) it seems that this has stopped working as expected and now the date property is empty all the time.

I'm using PHP to send the API request, so here is how I'm formatting my date prior to the API call.

strtotime($departureDate()->format('Y-m-d')) * 1000;

This works as expected from my local environment and this is sending a date value of 1548979200000 for example. Problem is, when I use the exact same code on my production server, the date property is not populated at all.

Lastly, it seems that the dates stopped populating via the API on May 11, 2018.

Thoughts? Thanks!

0 Upvotes
1 Reply 1
jmci
Member

Forms API Date Property

I wanted to post a quick update in case anyone has experienced a similar issue. I have since solved the issue and it looks like it was related to the date's timezone. Again, this was with PHP:

$myDate = new \DateTime('2018-07-16 09:00:00', new \DateTimeZone('UTC'));
$hubSpotDate = $date->format('U') * 1000;

Prior to this, I wasn't creating the new \DateTime object with a timezone. When I initialize the \DateTime object with UTC timezone, everything works as expected.