How to convert LDAP timestamp to Unix timestamp

后端 未结 5 2204
南方客
南方客 2020-12-05 14:59

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

5条回答
  •  眼角桃花
    2020-12-05 15:48

    Please see here.

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

提交回复
热议问题