正在使用
$datetime = date_create()->format('Y-m-d H:i:s');
它插入我的数据库但是 - 三个小时。 例如,我的时间是晚上9:30,它将插入18:30。 请帮助。解答
答案 0 :(得分:1)
你能试试吗,
g 12-hour format of an hour without leading zeros (1 through 12)
G 24-hour format of an hour without leading zeros (0 through 23)
h 12-hour format of an hour with leading zeros (01 through 12)
H 24-hour format of an hour with leading zeros (00 through 23)
<?php echo date('Y-m-d H:i:s'');?> // 24 Hours format
以下是TimeZone转换器,
PDT: America/Los_Angeles: <?php echo DatePNForServerTimeZone('D d M Y H:i:s A', 'America/Los_Angeles'); ?>
EST: America/New_York: <?php echo DatePNForServerTimeZone('D d M Y H:i:s A', 'America/New_York'); ?>
IST : Asia/Kolkata: <?php echo DatePNForServerTimeZone('D d M Y H:i:s A', 'Asia/Kolkata'); ?>
<?php
function DatePNForServerTimeZone($format='Y-m-d H:i:s', $Zone ='America/Los_Angeles'){
$utc = new DateTimeZone("UTC");
$new = new DateTimeZone($Zone);
$date = new DateTime(gmdate("m/d/Y H:i:s"), $utc);
$date->setTimezone($new);
return $date->format($format);
}
?>
答案 1 :(得分:0)