Hi, I am updating a date field to a date time field via the properties API. One thing I've noticed is that when I make the update, the value in the field is changing to the day before.
Date field value (mm/dd/yyyy): 12/15/2024
Date Time field value (mm/dd/yyyy): 12/14/2024 8:00 PM
This looks to be happening because my time zone is -4 hours from UTC. I'm wondering if there is a way to prevent this, so that the value just updates to midnight and keeps the same date?
dateString = '12/15/2024'; // MM/DD/YYYY date = new Date(dateString); original timestamp = date.valueOf(); adjustedTimestamp = original timestamp - (4 * 60 * 60 * 1000); now send this adjusted timestamp as a new property value in HubSpot. This should update the date with -4 hours time difference.
I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member. Thanks!
Hi @GRajput, thanks for the reply. Is there a way to do this when I'm updating the property type via the API from date to datetime, so that it just automatically applies to all values or would I need to do a seperate call to update the record values? If it's the latter, I'm thinking the easiest way may be to just export all records in a csv, use a formula to update the values with the proper offset and then import.
dateString = '12/15/2024'; // MM/DD/YYYY date = new Date(dateString); original timestamp = date.valueOf(); adjustedTimestamp = original timestamp - (4 * 60 * 60 * 1000); now send this adjusted timestamp as a new property value in HubSpot. This should update the date with -4 hours time difference.
I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member. Thanks!
what you can do is add the time differnce in the date you update. for ex; corrected time = originalDate + timezone offset (in hours) which I believe is 4 hours in your case so it will look like this "property": "2024-12-15T04:00:00Z"
I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member. Thanks!
Have a lovely day and thanks so much in advance for your help! Bérangère
HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates. Learn More.