I have a form field where a user can select the day, month and year however I would like to get the server hour, minute and second.
With my code
date("Y-m-d H:i:s", strtotime($_SESSION['form']['txtDate']))
produces 2013-04-27 00:00:00
where I would like 2013-04-27 16:30:55
for example.
Thanks
尝试这个
echo date("Y-m-d", strtotime($_SESSION['form']['txtDate'])) . " " . date("H:i:s");
如果你的会话没有存储小时,分钟和秒,那么你可以这样做,如下所示,
date("Y-m-d", strtotime($_SESSION['form']['txtDate'])) . " " . date("H:i:s")
尝试
date("Y-m-d", strtotime($_SESSION['form']['txtDate'])) . " " . date("H:i:s");
Use time() function it gives current time, with arguments Hi:i:s, see this for details. http://php.net/manual/en/function.time.php
$_SESSION['form']['txtDate']
应该有完整的格式,如2013-04-27 16:30:55
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.