Developer Announcements

AJLaPorte
HubSpot Product Team
HubSpot Product Team

New Standardization of date formats for HubSpot's Form Submissions API

What’s happening

Starting Tuesday, November 30th, 2022 we will be standardizing the format of dates for form submissions that are submitted through HubSpot’s Form Submission API’s to be in the following format:

 

date properties:

  • YYYY-MM-DD (ex: May 16 2022 would be 2022-05-16)
  • UTC midnight aligned unix millisecond timestamps (ex: May 16 2022 would be 1652659200000)

datetime properties:

  • YYYY-MM-DDThh:mm:ss.sTZD (ex: 1997-07-16T19:20:30.45+01:00)
  • Unix millisecond timestamps (ex: July 16 1997 7:20:30.45 PM UTC +1 would be 869077230045)

For existing forms, you can continue to use the date format that you've been using. For each HubSpot account, we've set a specific date format based on recent form submissions, so as long as all forms in the account remain consistent with the current format being used, date values will continue to be accepted.

 

New accounts, or existing accounts that use a new format compared to previous submissions, will receive an error if the date format does not match one of the formats detailed above.

 

After November 30th, 2022, form submissions via the API with dates that are not properly formatted will receive a 400 error response notifying them they are not in the proper format.

 

Any form submissions made via HubSpot’s embedded forms or through use of the forms module already adhere to this format.

 

What APIs does this apply to?

The standardization of the date format applies to all form submissions. This will include all submissions sent to the form submission API endpoints including:

Note: if you are using legacy v2 form submission endpoints, we recommend updating those endpoints to the latest v3 versions.

 

This will also affect values submitted in HubSpot embedded forms, so if you are manipulating field values in embedded forms, you will also need to use this format when changing the values for date fields.

3 Replies 3
KimJ
Participant

New Standardization of date formats for HubSpot's Form Submissions API

I'm printing the deal close date in an email via HubL. How do I get this to format in a readable date format?

 

Here's the code snippet: <em>Congratulations</em> for taking a career-transforming step on {{ deal.closedate }} 

And the output: Congratulations for taking a career-transforming step on 1663645320000 

 

Thanks!

0 Upvotes
doublejosh
Participant

New Standardization of date formats for HubSpot's Form Submissions API

Any recommended elegant ways to generate a "UTC midnight aligned unix millisecond timestamp" in this unique HubSpot format (in javascript when setting fields in forms)?

 

I thought this might work, but it comes in as invalid. I guess it's not actually "midnight aligned"?

Math.round(new Date().valueOf() / 100000) * 100000;

 

Seems like the fast way is to slice the ISO date, but that doesn't round to the nearest midnight and it turns out different browsers output a different string anyway.

new Date().toISOString().slice(0, 10);

 

Not elegant, but this is where I landed...

const roundSimpleDate = (date) =>

  date.getUTCFullYear() + "-" +

  ("0" + (date.getUTCMonth() + 1)).slice(-2) + "-" +

  ("0" + (date.getUTCHours() > 12 ? date.getUTCDate() + 1 : date.getUTCDate())).slice(-2);

 

I can't imagine why this weird date type exists (which is also the only option via the UI). I guess it's commonly used with a date picker, but the digits are available in the data type... so why bother to distinguish? It just adds pain when used as hidden fields.

0 Upvotes
AJLaPorte
HubSpot Product Team
HubSpot Product Team

New Standardization of date formats for HubSpot's Form Submissions API

Hi @doublejosh,

 

@dennisedson was able to put together the following codepen to help with your question. Please feel free to review this codepen below:

https://codepen.io/billyoncetoldme/pen/QWxoajg?editors=1111

 

I hope this helps point you in the right direction.

-AJ