开发者

Problem with converting Date and Time to Datetime Format

everyone..

I'm on the way to find out why this code is not able to work :(

  $timeku = "3:00 PM";
  $dateku = "08/24/2011";
  $date_ku = explode("/",$dateku);
  $date_new = $date_ku[2]."-".$date_ku[1]."-".$date_ku[0];
  $datetime_ku = date('Y-m-d H:i:s',strtotime($date_new.' '.$timeku))开发者_JAVA百科;

every i try to insert data $datetime_ku to mysql database it always result : 1970-01-01 07:00:00

Why? and how to solve it?

Thanks in advance.


This works for me:

$datetime_ku = date('Y-m-d H:i:s', strtotime('08/24/2011'.'3:00 PM'));


Correct way to do the same

$date = new DateTime("$dateku $timeku");
$datetime_ku = $date->format("Y-m-d H:i:s");
echo $datetime_ku;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜