PHP Unix 秒时间到 PHP UTC 时间(毫秒)
有没有办法将 PHP 中的 Unix 秒时间转换为 PHP UTC 时间(毫秒)?我试图将时间传递给 HubSpot 中的 datepicer 属性,但我无法让 API 接受它想要的内容。
这就是我得到的:
$time = 1632182399;
我做了一些研究,发现一位贡献者建议了这个解决方案: https://community.hubspot.com/t5/APIs-Integrations/Update-Custom-Date-Picker-in-Deals-through-the-API/mp/229499
但这实际上并不工作,我不知道为什么。也许我叫错了?这就是我正在尝试的:
function get_time_for_hubspot($time){
$target_date = date( 'Y-m-d', strtotime( $time ) );
$timezone_object = new \DateTimeZone( 'UTC' );
$date_object = new \DateTime( $target_date, $timezone_object );
return $date_object->format( 'U' ) * 1000;
}
// Time Stamps
$starttime = strval($booking_object->start);
$endtime = strval($booking_object->end);
$starttime = get_time_for_hubspot($starttime);
$endtime = get_time_for_hubspot($endtime);
感谢您的帮助。
is there a way to convert a Unix Seconds time in PHP to a PHP UTC time with Milliseconds? I'm trying to pass the time to the datepicer property in HubSpot but I can't get the API to accept what it wants.
Here's what I got:
$time = 1632182399;
I had did some research and found a contributor had suggested this solution:
https://community.hubspot.com/t5/APIs-Integrations/Update-Custom-Date-Picker-in-Deals-through-the-API/m-p/229499
But this doesn't actually work and I don't know why. Perhaps I'm calling it wrong? This is what I was trying:
function get_time_for_hubspot($time){
$target_date = date( 'Y-m-d', strtotime( $time ) );
$timezone_object = new \DateTimeZone( 'UTC' );
$date_object = new \DateTime( $target_date, $timezone_object );
return $date_object->format( 'U' ) * 1000;
}
// Time Stamps
$starttime = strval($booking_object->start);
$endtime = strval($booking_object->end);
$starttime = get_time_for_hubspot($starttime);
$endtime = get_time_for_hubspot($endtime);
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论