Posted on 2007-10-16 22:57
itspy 阅读(294)
评论(0) 编辑 收藏
/**formate datetime to timestamp**/
function convert_datetime($str) {
list($date, $time) = explode(' ', $str);
list($year, $month, $day) = explode('-', $date);
list($hour, $minute, $second) = explode(':', $time);
$timestamp = mktime($hour, $minute, $second, $month, $day, $year);
return $timestamp;
}
/**formate timestamp to datetime **/
function convert_timestamp ($timestamp)
{
return strftime ("%Y-%m-%d %H:%M:%S", $timestamp);
}
/**formate m/d/y to datetime, in order to store to DB**/
function getDateTime($strtime){
$array = explode("/",$strtime);
$month = $array[0];
$day = $array[1];
$year = $array[2];
#int mktime ( [int $hour [, int $minute [, int $second [, int $month [, int $day [, int $year [, int $is_dst]]]]]]] )
$timestamp =mktime(0,0,0,$month,$day,$year);
return convert_timestamp($timestamp);
}