php date problem
hi, i have a form in which the user has to enter a date in the format dd-mm-yyyy. it can be any date. i want to store the previous day in my database.
eg: if the date entered is 01-01-2009 then the new date that should be entered to data base should be 31-12-2008.
can some one pls help me with this.
thanks in advance..
$date = '31-12-2008';
$date = strtotime($date);
$date = $date-(3600*24) //Minus one day in seconds
A day isn't precisely 24 hours.
Use international date format where possible, it makes working with dates easier.
$date = date('Y-m-d', strtotime('2008-01-01 -1 days'));