I am echo $date from mysql $date=2008-01-02 how to do "(2008-01-02) - (0000-00-01)"=2008-01-01 in php programming is it possible? i have try $date=date("$date",Time()-24*3600); but not working. help me out thank you
I would suggest using mktime() or strtotime for getting this done <?php $tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y")); $lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); $nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y")+1); ?> PHP: This will enable you to add and subtracts days, yars, months etc.
Using strtotime() <? $date='2008-01-02'; $timestamp = strtotime('-1 day', strtotime($date)); echo date('Y-m-d',$timestamp); ?> PHP: