I store some error_log with date for their name. like 20120827.txt
Now I write some php script for view the error_log.
I need do some judgment:
if(file_exists(date("Ymd").'.txt')){
$html = file_get_contents(date("Ymd").'.txt');
}else{
$html = file_get_contents((date("Ymd")-1).'.txt');//load yesterday's `error_log`.
}
But this not suit the date like 20120801.txt, How to do date("Ymd")-1?
I tried date("Ymd", (strtotime($date) . " -1 day"));// return:19700101
If you want yesterday’s date you can do
Or you could use the
DateTimeobject: