Type: Full Script
License: GNU General Public License
Description: Converts an LDAP timestamp of the form yyyymmddhhmmsst to a Unix timestamp.
<?php //PHP script to convert a timestamp returned from an LDAP query into a Unix timestamp // The date as returned by LDAP in format yyyymmddhhmmsst $date = "20030218045359Z"; // Get the individual date segments by splitting up the LDAP date $year = substr($date,0,4); $month = substr($date,4,2); $day = substr($date,6,2); $hour = substr($date,8,2); $minute = substr($date,10,2); $second = substr($date,12,2); // Make the Unix timestamp from the individual parts $timestamp = mktime($hour, $minute, $second, $month, $day, $year); // Output the finished timestamp echo "Date was ".$month."/".$day."/".$year." ".$hour.":".$minute.":".$second." but is now ".$timestamp."n"; ?>