gpt4 book ai didi

php - 如何将 LDAP 时间戳转换为 Unix 时间戳

转载 作者:可可西里 更新时间:2023-10-31 22:09:36 25 4
gpt4 key购买 nike

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

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

最佳答案

请参阅here .

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

$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);

关于php - 如何将 LDAP 时间戳转换为 Unix 时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4647169/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com