As my server is not upgreaded to php 5.3 (it is in PHP Version 5.2.11) date_sub is not working.
here is the code: $date = date_create(date('Y-m-d'));
                date_sub($date, date_interval_create_from_date_string('60 days'));
                $date1= date_format($date, 'Y-m-开发者_JS百科d');
but its ok in my localhost(which is in 5.3), but not in server(5.2.11).
Can you please tell me how can i make this date subtraction working on 5.2.11 ?
Like the docs say, use DateTime::modify().
$date1= date('Y-m-d', strtotime("-60 days"));
it works :)
For adding and subracting days
$newdate = date('Y-m-d', strtotime("-10 days"));
echo $newdate;
sub 10 days
$newdate1 = date('Y-m-d', strtotime("+10 days"));
echo $newdate1;
add 10 days
For adding and subracting months
$newmonth = date('Y-m-d', strtotime("-5 months"));
echo $newmonth;
sub 10 months
$newmonth1 = date('Y-m-d', strtotime("+5 months"));
echo $newmonth1;
add 10 months
As the manual page says, this function works only for the PHP version >= 5.3.0.
So, you've found right solution yourself
for EX $da=2014-04-01
if u want to minus 6 months use this..
$date = strtotime($da .' -6 months');
$final=date('Y-m-d', $date);
echo $final;
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论