how to get date of yesterday using php?

前端 未结 9 1639
悲&欢浪女
悲&欢浪女 2021-01-30 04:51

I want to get the yesterday date using specific date format in php this is the format:

$today = date(\"d.m.Y\"); //15.04.2013

Is it possible?

9条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-30 05:39

    Another OOP method for DateTime with setting the exact hour:

    $yesterday = new DateTime("yesterday 09:00:59", new DateTimeZone('Europe/London'));
    echo $yesterday->format('Y-m-d H:i:s') . "\n";
    

提交回复
热议问题