Search code examples
phpldaptimestamp

How to convert LDAP timestamp to Unix timestamp


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".

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


Solution

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