# Valid formats for date fields when posting via HubSpot API

**URL:** <https://community.hubspot.com/t/valid-formats-for-date-fields-when-posting-via-hubspot-api/11763>\
**Category:** APIs & Integrations\
**Tags:** forms\
**Created:** [August 11, 2016, 3:51pm UTC](https://community.hubspot.com/t/valid-formats-for-date-fields-when-posting-via-hubspot-api/11763 "2016-08-11T15:51:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [August 11, 2016, 3:51pm UTC](https://community.hubspot.com/t/valid-formats-for-date-fields-when-posting-via-hubspot-api/11763/1 "2016-08-11T15:51:37Z")

</div>

Hi.

I’m trying to figure out a (or the) correct format for sending date parameters via a POST request to a form with a date picker via the `/uploads/form/v2/:portal_id/:form_guid` endpoint.

I first tried `yyyy-mm-dd` format, e.g., for August 15, 2016 I sent `2016-08-15`. Although this seems to be interpreted correctly when you view submissions for that particular form, when looking at the associated Contact that it creates or updates, the date field displays `Invalid date` in red.

On the other hand, sending the date in `mmm dd yyyy`, e.g. `Aug 15 2016`, displays the date as `Invalid date` when viewing submissions to the form, but when drilling down to a specific Contact, the date displays correctly.

Assuming I’d prefer the latter — that this date get written to the Contact’s record correctly — is `mmm dd yyyy` the format of choice to send via this endpoint? Is there a standard format for sending date parameters to the HubSpot API that would be correctly interpreted in both cases? Can I decouple the way dates are displayed in HubSpot and how I choose to send them via the API by some admin setting?

Thanks for any help you can provide.

---

<div class="post-metadata">

**Author:** ![Dadams](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dadams/32/21752_2.png) [@Dadams](https://community.hubspot.com/u/Dadams)\
**Post date:** [August 11, 2016, 10:13pm UTC](https://community.hubspot.com/t/valid-formats-for-date-fields-when-posting-via-hubspot-api/11763/2 "2016-08-11T22:13:24Z")

</div>

Hi [@O-I](https://community.hubspot.com/u/o-i)

Date properties need to be set as UNIX formatted timestamps, in milliseconds. As an example, you would use 1430438400000 as the value for the time 01 May 2015 00:00:00 UTC. This goes for form submissions as well as updates made through the Contacts API.

More details can be found here:  
 [developers.hubspot.com](https://developers.hubspot.com/docs/faq/how-should-timestamps-be-formatted-for-hubspots-apis)

### [How should timestamps be formatted for HubSpot’s APIs?](https://developers.hubspot.com/docs/faq/how-should-timestamps-be-formatted-for-hubspots-apis)

HubSpot API endpoints accept UNIX formatted timestamps in milliseconds. Most scripting languages have built-in functions or existing libraries that handle time conversion, but you must ensure that your timestamp values are in the correct UNIX…

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [August 12, 2016, 2:17am UTC](https://community.hubspot.com/t/valid-formats-for-date-fields-when-posting-via-hubspot-api/11763/3 "2016-08-12T02:17:29Z")

</div>

Thanks for the quick response and helpful link, @dadams.

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [January 5, 2018, 8:48pm UTC](https://community.hubspot.com/t/valid-formats-for-date-fields-when-posting-via-hubspot-api/11763/4 "2018-01-05T20:48:09Z")

</div>

If anyone stumbles upon this thread and is looking for a solution using Ruby/Rails, here’s how I had to do it:

```auto
def hubspot_formatted_date(date)
 return nil if date.nil?

 Time.utc(date.year, date.month, date.day).strftime('%s%3N')
end

```

That last strftime puts it in 13-digit format.

---

<div class="post-metadata">

**Author:** ![agjoligu](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/agjoligu/32/48165_2.png) [@agjoligu](https://community.hubspot.com/u/agjoligu)\
**Post date:** [May 4, 2018, 2:17pm UTC](https://community.hubspot.com/t/valid-formats-for-date-fields-when-posting-via-hubspot-api/11763/5 "2018-05-04T14:17:24Z")

</div>

I am having some trouble submitting post requests to create a deal because the timestamp value for a date picker property is not being accepted by the hubspot api. Here is the timestamp value 1206331200000. The date is 3/24/2008. The API accepts the value of 1430438400000 that you list above but not my value. I have run my value through some online converters and it shows as being valid. Why is the Hubspot API returning bad request when this value is included in the request.

---

<div class="post-metadata">

**Author:** ![Derek\_Gervais](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/derek_gervais/32/17429_2.png) [@Derek\_Gervais](https://community.hubspot.com/u/Derek_Gervais)\
**Post date:** [May 8, 2018, 2:55pm UTC](https://community.hubspot.com/t/valid-formats-for-date-fields-when-posting-via-hubspot-api/11763/6 "2018-05-08T14:55:32Z")

</div>

Hi [@InProductionDev](https://community.hubspot.com/u/inproductiondev),

That timestamp value is midnight 3/24/2008 ET, not midnight UTC. UTC midnight 3/24/2008 would be `1206316800000`.
