Write a PHP script to add/subtract the number of days from a particular date.
<?php $dt='2011-01-01'; echo 'Original date : '.$dt."\n"; $no_days = 40; $bdate = strtotime("-".$no_days." days", strtotime($dt)); $adate = strtotime("+".$no_days." days", strtotime($dt)); echo 'Before 40 days : '.date("Y-m-d", $bdate)."\n"; echo 'After 40 days : '.date("Y-m-d", $adate)."\n"; ?>
Sample Output:
Original date : 2011-01-01 Before 40 days : 2010-11-22 After 40 days : 2011-02-10
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer