php ldap timestamp转换器

时间:2015-05-11 13:16:16

标签: php ldap

我试图将ldap时间戳转换为日期格式。下面是我使用的代码,但输出没有准确。

以下是代码:

$time = strtotime('20150709142652Z');  
echo date('d M, Y H:m:s A T',$time);

我的输出:09 Jul, 2015 19:07:52 PM IST

我正在将此输出与此网站进行比较:http://www.epochconverter.com/epoch/ldap-timestamp.php

请告诉我在我的代码中要更改什么内容?

2 个答案:

答案 0 :(得分:0)

此问题已通过此代码

回答here
$fileTime = "20150709142652Z";
$winSecs       = (int)($fileTime / 10000000); // divide by 10 000 000 to get seconds
$unixTimestamp = ($winSecs - 11644473600); // 1.1.1600 -> 1.1.1970 difference in seconds
echo date('d M, Y H:m:s A T',$unixTimestamp);

“技巧”是首先将其转换为unix时间戳,然后给出正确的格式。

答案 1 :(得分:0)

实际上您的代码和输出是正确的

此转换器(https://www.epochconverter.com/ldap)使用本地时间戳记。请检查格林尼治标准时间或当地时区以比较您的结果。

enter image description here

相关问题