Home > Backend Development > PHP Tutorial > PHP bug strtotime

PHP bug strtotime

WBOY
Release: 2016-06-23 13:03:49
Original
916 people have browsed it

echo date('Y-m',strtotime('-1 months'));
echo "\r\n";
echo date('Y-m',strtotime('first day of last month'));
echo "\r\n";
echo date('Y-m',strtotime('-1 week'));




当遇到月为31日是 date('Y-m',strtotime('-1 months'));求的月份还是当月的

正确使用方式

echo date('Y-m',strtotime('first day of last month'));


echo date('Y-m-d H:i:s', strtotime('-1 month', strtotime(date('Y-m'))));

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template