PHP date() function not giving correct time

前端 未结 4 1631
清酒与你
清酒与你 2021-01-25 04:34

I am trying to figure out why php date() is giving me the wrong time, setting the actual time back 2 hours.


4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-25 05:18

    //Change date format

    $dateInfo = date_parse_from_format('m-d-Y', $data['post_date']);
    $unixTimestamp = mktime(
            $dateInfo['hour'], $dateInfo['minute'], $dateInfo['second'],
            $dateInfo['month'], $dateInfo['day'], $dateInfo['year']
        );
    $data['post_date']=date('Y-m-d',$unixTimestamp);
    

提交回复
热议问题