我想得到一个月的第一天00:00:00的时间戳。
例如,时间戳为Jan 01 2012 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;这将返回当月当前一天的零小时,而不是月初。
有什么建议吗?
发布于 2012-06-28 08:55:02
试试这个:
echo date( 'F jS Y h:i:s A', strtotime( 'first day of ' . date( 'F Y')));这将输出:
June 1st 2012 12:00:00 AM发布于 2012-06-28 08:54:02
尝尝这个
$time = strtotime(date('Y-m-01 00:00:00')); // == 1338534000翻译过来就是:
$date = date('Y-m-d H:i:s', $time); // == 2012-06-01 00:00:00请阅读有关date()和time()函数的PHP手册。
发布于 2017-05-27 13:39:47
echo date("Y-m-d 00:00:00", strtotime("first day of this month"));这将输出以下内容:
2017-05-01 00:00:00https://stackoverflow.com/questions/11236708
复制相似问题