[英]Using just strtotime, 0 am first day of this month in PHP?
echo mydate(strtotime('1 am first day of this month'));
Above works with result 2017-10-01 01:00:00
, but I have difficulty to do it for 0 am. 上面的结果为
2017-10-01 01:00:00
,但是我很难在凌晨0点做。 Neither 24am, 24pm, 0pm, first second
works. 24am, 24pm, 0pm, first second
都24am, 24pm, 0pm, first second
。
Better to use DateTime
for date and time manipulations, 最好使用
DateTime
进行日期和时间操作,
$date = new DateTime('midnight first day of this month'); echo $date->format('Ymd H:i:s');
or if there is need to UnixTimestamp : $date->format('U');
或者如果需要UnixTimestamp:
$date->format('U');
date- $date->format('U');
or echo $date->getTimestamp();
或
echo $date->getTimestamp();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.