How to increment decrement date in php

    To increment/decrement date in php you can use simple process as follows:
    <?php
    $your_date
    = '2011-05-20';

    //You need to increment it by 2 day

    //Convert to time stamp first

    $your_date_ts = strtotime($your_date);

    //Increment By 2 Day

    $your_date_dt = strtotime('+2 day', $your_date_ts);

    echo
    date('Y-m-d', $your_date_dt);

    //Increment By 2 Week

    $your_date_tw = strtotime('+2 week', $your_date_ts);

    echo
    date('Y-m-d', $your_date_tw);

    //Similar process is followed for decrement just user -2 day or -2 week in place of +1 day or +1 week

    //Decrement By 2 Day

    $your_date_dd = strtotime('-2 day', $your_date_ts));

    echo
    date('Y-m-d', $your_date_dd);

    //Decrement By 2 Week

    $your_date_wd = strtotime('-2 week', $your_date_ts);

    echo
    date('Y-m-d', $your_date_wd);
    ?>
    5
    Average: 5 (1 vote)