# 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:** 1\
**Showing post:** 4

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

---

_[View the full topic](https://community.hubspot.com/t/valid-formats-for-date-fields-when-posting-via-hubspot-api/11763)._
