且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何找出日期前一天的日期?

更新时间:2021-11-11 08:48:18

strtotime( )就能解决问题.使用 mktime()将您以前的日期转换为Unix时间戳,然后使用像这样:

strtotime() will do the trick. Convert your previous date to a Unix timestamp using mktime(), then use it like this:

$from_unix_time = mktime(0, 0, 0, $month, $day, $year);
$day_before = strtotime("yesterday", $from_unix_time);
$formatted = date('Y-m-d', $day_before);