I am trying to post a date field to the HubSpot contact API, however, I am getting errors stating a UTC date is not midnight.
"1505779200 is at 10:16:19.200 UTC, not midnight!"
However, if you use this tool, and enter that value you will see that the value is midnight.
The c# code I use to do the conversion is:
public static double DateTimeToUTC(System.DateTime dateTime)
{
dateTime = System.DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);
var utcValue = ((DateTimeOffset) dateTime).ToUnixTimeSeconds();
return utcValue;
}
Can anyone help?
Cheers
KH
Have you tried posting the UNIX time in milliseconds (rather than seconds)? HubSpot FAQ here
Try switching to
.toUnixTimeMilliseconds()
and give it a whirl! (MSDN Ref)