如何将LDAP时间戳转换为Unix时间戳 [英] How to convert LDAP timestamp to Unix timestamp

查看:292
本文介绍了如何将LDAP时间戳转换为Unix时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用PHP检索Active Directory的LDAP属性"pwdLastSet"时,得到的值类似于1.29265206716E + 17.我知道这个值代表日期"2010年8月17日星期二14:11:11 GMT + 0200".

When I retrieve the LDAP attribute "pwdLastSet" of an Active Directory using PHP I get a value like 1.29265206716E+17. I know that this value represents the date "Tue Aug 17 2010 14:11:11 GMT+0200".

如何在PHP中将此值转换为Unix时间戳?感谢您的提示!

How can I convert this value to a Unix timestamp in PHP? Thanks for any hints!

推荐答案

请参阅此处.

实际上,归结为将FILETIME时间戳转换为UNIX时间戳:

Actually it boils down to converting the FILETIME timestamp into a UNIX timestamp:

$fileTime = "130435290000000000";
$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(DateTime::RFC822, $unixTimestamp);

这篇关于如何将LDAP时间戳转换为Unix时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆