向 HubSpot 发布日期时出错 API
Error posting date to HubSpot API
我正在尝试 post HubSpot 联系人 API 的日期字段,但是,我收到错误消息,指出 UTC 日期不是午夜。
"1505779200 is at 10:16:19.200 UTC, not midnight!"
但是,如果您使用此 tool,并输入该值,您将看到该值是午夜。
我用来进行转换的 C# 代码是:
public static double DateTimeToUTC(System.DateTime dateTime)
{
dateTime = System.DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);
var utcValue = ((DateTimeOffset) dateTime).ToUnixTimeSeconds();
return utcValue;
}
有人能帮忙吗?
干杯
KH
您是否尝试过以毫秒(而不是秒)为单位发布 UNIX 时间? HubSpot FAQ here
HubSpot API endpoints accept UNIX formatted timestamps in milliseconds. ...
...
Date/Datetime properties in HubSpot Contacts
Date properties will only store the date, and must be set to midnight UTC for the date you want. For example, May 1 2015 would be 1430438400000 (01 May 2015 00:00:00 UTC). If you try to set a value that is not midnight UTC, you will receive an error.
尝试切换到 .toUnixTimeMilliseconds()
并试一试! (MSDN Ref)
public static double DateTimeToUTC(System.DateTime dateTime)
{
dateTime = System.DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);
var utcValue = ((DateTimeOffset) dateTime).ToUnixTimeMilliseconds();
return utcValue;
}
我正在尝试 post HubSpot 联系人 API 的日期字段,但是,我收到错误消息,指出 UTC 日期不是午夜。
"1505779200 is at 10:16:19.200 UTC, not midnight!"
但是,如果您使用此 tool,并输入该值,您将看到该值是午夜。
我用来进行转换的 C# 代码是:
public static double DateTimeToUTC(System.DateTime dateTime)
{
dateTime = System.DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);
var utcValue = ((DateTimeOffset) dateTime).ToUnixTimeSeconds();
return utcValue;
}
有人能帮忙吗?
干杯
KH
您是否尝试过以毫秒(而不是秒)为单位发布 UNIX 时间? HubSpot FAQ here
HubSpot API endpoints accept UNIX formatted timestamps in milliseconds. ...
...
Date/Datetime properties in HubSpot Contacts
Date properties will only store the date, and must be set to midnight UTC for the date you want. For example, May 1 2015 would be 1430438400000 (01 May 2015 00:00:00 UTC). If you try to set a value that is not midnight UTC, you will receive an error.
尝试切换到 .toUnixTimeMilliseconds()
并试一试! (MSDN Ref)
public static double DateTimeToUTC(System.DateTime dateTime)
{
dateTime = System.DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);
var utcValue = ((DateTimeOffset) dateTime).ToUnixTimeMilliseconds();
return utcValue;
}