Hello. Does anyone know how I would go about getting the date from the previous day in PHP? I can get the current days date using:
$date = date("dmY");
(that is the format that I want it)
though if i wanted yesturdays date, that would be harder to get becuase the days system isn't based on 100 (grr to whoever made the date system ). If anyone could help me that would be great

(eg. If i tried 03112005 - 1 it would = 03112004 )


I tried: $yesturday = mktime(0, 0, 0, date("m") , date("d")-1, date("Y"));
though that didn't work the way I wanted 😢

    $date = date("dmY", strtotime('-1 day'));

    should work, but I didn't test. if not, check the strtotime() function documentation.

      
      $time = time() - (24 * 60 * 60);
      
      $date = date("dmY", $time);
      
      
        Napster wrote:
        
        $time = time() - (24 * 60 * 60);
        
        $date = date("dmY", $time);
        
        

        But remember that not all days are twenty-four hours long.

          Write a Reply...