CoderZone.org

Category: >> PHP Code >> LDAP Timestamp Converter Bookmark and Share

<< lastnext >>

Snippet Name: LDAP Timestamp Converter

Description: Converts an LDAP timestamp of the form yyyymmddhhmmsst to a Unix timestamp.

Also see:
» Convert Minutes to Days, Hours, an...
» Resize and convert an image to a P...
» Convert text to image in php
» Get Unix Timestamp for midnight to...
» Convert RGB to Hex with ASP
» Convert a String to Title Case in ...
» Convert Extensions To Lowercase
» Tabs-To-Space Converter
» Convert Unix time string to a date...
» Convert Dollars And Cents Value to...
» Convert entities into normal chara...
» Convert Seconds to Hours:Minutes:S...
» Convert UK Dates To mySQL Format D...
» Convert miles to feet, feet to mil...
» Converting Rows to Columns
» TO_TIMESTAMP_TZ
» TO_TIMESTAMP
» TIMESTAMP_TO_SCN
» SCN_TO_TIMESTAMP
» CONVERT
» TIMESTAMP: TZ_OFFSET
» TIMESTAMP: TRUNC
» TIMESTAMP: SysTimeStamp
» TIMESTAMP: SYS_EXTRACT_UTC
» TIMESTAMP: SessionTimeZone
» TIMESTAMP: LocalTimestamp
» TIMESTAMP: FROM_TZ
» TIMESTAMP: EXTRACT
» TIMESTAMP: DUMP

Comment: (none)

Author: CoderZone
Language: PHP
Highlight Mode: PHP
Last Modified: December 02nd, 2010

<?php
// converts an LDAP-style timestamp to a Unix timestamp
// The date as returned by LDAP in format yyyymmddhhmmsst
 
$date = "20100521045359Z";
 
// Get the 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
print "Date was ".$month."/".$day."/".$year." ".$hour.":".$minute.":".$second." but is now ".$timestamp."\n";
?>
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 5