Jump to content

Getting day before on a set date (not todays date)


dc_jt

Recommended Posts

You can use the strtotime() function:

<?php
$date = '2007-02-01';
$day_before = date('Y-m-d',strtotime($date . ' -1 day'));
echo $day_before;
?>

Or you can get the UNIX timestamp of the date and subtract 86,400 (the number of seconds in a day) from it:

<?php
$date = '2007-02-01';
$day_before = date('Y-m-d',strtotime($date) - 86400);
echo $day_before;
?>

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.