php dates

Discussion in 'Software' started by PeterK2003, Apr 14, 2006.

  1. PeterK2003

    PeterK2003 Private E-2

    i what to figure out the date that is excatly 30 before the current in php. I can get the current date but i don't know how to subtract 30 days from it. Any suggestions?

    Thanks.

    Peter
     
  2. Arcantos

    Arcantos Private E-2

    PHP:
    <?php
    $lastday 
    mktime(000date('m'),date('d')-30,date('Y'));
    echo 
    strftime("The date 30 days ago was: %m/%d/%Y"$lastday);
    ?> 
    That takes 30 days off the date and gives it back to you in mm/dd/yyyy.

    Should work. :)
     
  3. PeterK2003

    PeterK2003 Private E-2

    will that account for months that have different number of days?
     
  4. Arcantos

    Arcantos Private E-2

    Yep, should do.
     
  5. PeterK2003

    PeterK2003 Private E-2

    ok i'll try it.

    thanks
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds