coffee_cn

博客园 首页 新随笔 联系 订阅 管理
// 2018/2/13 00:26:00.000
function format_date($date, $format='Y-m-d H:i:s') {
    if(empty($date)) return $date;
    $arr = preg_split("/[\s\/:.-]+/", $date);
    $year = intval($arr[0]);
    $month = intval($arr[1]);
    $day = intval($arr[2]);
    $hour = intval($arr[3]);
    $minute = intval($arr[4]);
    $second = intval($arr[5]);
    $time = mktime($hour, $minute, $second, $month, $day, $year);
    return date($format, $time);
}
$date = format_date($date);
echo($date);

2018-02-13 00:26:00

 

posted on 2019-07-17 09:59  coffee  阅读(330)  评论(0编辑  收藏  举报