Many applications including the ubiquitoius qmail, use tai64n time format for thier logs. A tai64 number looks rather cryptic to the unprepared but here we show a simple method of converting this to a human readable format. The function below returns a unix timestamp which we can use with PHP's date() function to create dates in any human readable format we wish. Here we also see the date() function used to create a MySQL type TIMESTAMP.



// an example tai64n number as supplied by qmail ***/
$tai64_number '@400000003c675d4000fb2ebc';

date('Y-m-d h:i:s'tai64_to_timestamp($tai64_number));

* Convert a tai64 to a unix timestamp
* @usage
* $tai64_number = '@400000003c675d4000fbebc';
* echo tai64_to_timestamp($tai64_number);
* @string A valid tai64 number
* @return INT unix timestamp
function tai64_to_timestamp($tai64_number){

/***  remove @ sign ***/
$tai64_number str_replace'@4''0'$tai64_number );

/*** strip last 8 chars ***/
$tai64_number substr$tai64_number0, -);

/*** convert to unix timestamp and hexdec ***/
return intvalhexdec$tai64_number ) );