how to get date of yesterday using php?

前端 未结 9 1641
悲&欢浪女
悲&欢浪女 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:21

    try this

            $tz    = new DateTimeZone('Your Time Zone');
            $date  = new DateTime($today,$tz);
            $interval = new DateInterval('P1D');
            $date->sub($interval); 
    
            echo $date->format('d.m.y');
    
            ?>           
    

提交回复
热议问题