UNIX TIMESTAMP: Is the time measured in seconds since the start of the Unix epoch “1 January 1970”
Use the PHP time function as per example below
echo time(); //Will print out the current timestamp
//OUTPUT: 1285365600
echo time(); //Will print out the current timestamp
//OUTPUT: 1285365600
<?php
$DATETIME = '2010-04-22 19:54:38';
echo convertDateTime($DATETIME);
/*
* This function converts a mysql datetime to a unix timestamp
* The format should be "YYYY-MM-DD HH:MM:SS"
*
* @param $datetime string Contains the DATETIME value
* @return UNIX TIMESTAMP
*/
function convertDateTime($datetime) {
list($date, $time) = explode(' ', $datetime);
list($year, $month, $day) = explode('-', $date);
list($hours, $minutes, $seconds) = explode(':', $time);
$UnixTimestamp = mktime($hours, $minutes, $seconds, $month, $day, $year);
return $UnixTimestamp;
}
?>
<?php
$DATETIME = '2010-04-22 19:54:38';
echo convertDateTime($DATETIME);
/*
* This function converts a mysql datetime to a unix timestamp
* The format should be "YYYY-MM-DD HH:MM:SS"
*
* @param $datetime string Contains the DATETIME value
* @return UNIX TIMESTAMP
*/
function convertDateTime($datetime) {
list($date, $time) = explode(' ', $datetime);
list($year, $month, $day) = explode('-', $date);
list($hours, $minutes, $seconds) = explode(':', $time);
$UnixTimestamp = mktime($hours, $minutes, $seconds, $month, $day, $year);
return $UnixTimestamp;
}
?>
Hello Friends! I am Ramana a part time blogger from Hyderabad.