[英]How to get timestamp of current month, first day of month, zero hour
我想在00:00:00获得该月第一天的时间戳。
例如,2012年1月1日00:00:00的时间戳
我这样做:
$test_month = time(); // Seconds
$test_month = date('M', $test_month); // This month
$test_month = strtotime($test_month); // Timestamp of this month
echo $test_month;
这是返回当月当天的零小时,而不是月初。
有什么建议么?
尝试这个:
echo date( 'F jS Y h:i:s A', strtotime( 'first day of ' . date( 'F Y')));
这将输出:
June 1st 2012 12:00:00 AM
echo date("Y-m-d 00:00:00", strtotime("first day of this month"));
这输出:
2017-05-01 00:00:00
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.