Convert to mysql TIMESTAMP
How can i convert this values to insert into mysql TIMESTAMP.
开发者_运维技巧$time=12 am;
$time=date("H:i:s", strtotime($mtime));
the above thing doesn't work
is there any better solution to do this.
I think the problem is you're seeing '00:00:00' and assuming that's wrong...it's not. '00:00:00' is how midnight is represented. If you want to get today at midnight this will do it:
$now = time();
$time = mktime(0, 0, 0, date('m', $now), date('d', $now), date('Y', $now));
$time = date("Y-m-d H:i:s", $time);
This will return a string like this: 2011-10-04 00:00:00
which I think is what you're after.
$time = "12am";
$time=date("H:i:s", strtotime($time));
That should work
$time=12 am;
$time=date("H:i:s", strtotime($mtime));
$time = 12 am
, but you're trying strtotime($mtime)
. maybe your problem in wrong variable?
精彩评论