How to convert LDAP timestamp to Unix timestamp(如何将 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 时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何将 LDAP 时间戳转换为 Unix 时间戳


基础教程推荐
- 超薄框架REST服务两次获得输出 2022-01-01
- 在多维数组中查找最大值 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01