Tag Archives: get 1 year back date in php

get old date or new date from current date in php


<?php 

$date= strtotime(date('Y-m-d'));
//echo date('d-m-Y', strtotime($date));
//echo date('d F Y');


/** get the new date from current date **/


// added 1 day to current date..
$newDateDay = date('Y-m-d',strtotime('+1 day',$date)); 
echo $newDateDay;
echo '<br/>';


// added 15 days to current date..
$newDateDays = date('Y-m-d',strtotime('+15 days',$date)); 
echo $newDateDays;
echo '<br/>';


// added 1 week to current date..
$newDateWeek = date('Y-m-d',strtotime('+1 week',$date)); 
echo $newDateWeek;
echo '<br/>';


// added 1 Month to current date..
$newDateMonth = date('Y-m-d',strtotime('+1 month',$date)); 
echo $newDateMonth;
echo '<br/>';


// added 1 year to current date..
$newDateYear = date('Y-m-d',strtotime('+1 year',$date)); 
echo $newDateYear;
echo '<br/>';



/** get the past date from current date **/


// subtract 1 day to current date..
$newDateDay = date('Y-m-d',strtotime('-1 day',$date)); 
echo $newDateDay;
echo '<br/>';


// subtract 15 days to current date..
$newDateDays = date('Y-m-d',strtotime('-15 days',$date)); 
echo $newDateDays;
echo '<br/>';


// subtract 1 week to current date..
$newDateWeek = date('Y-m-d',strtotime('-1 week',$date));
echo $newDateWeek;
echo '<br/>';


// subtract 1 Month to current date..
$newDateMonth = date('Y-m-d',strtotime('-1 month',$date));
echo $newDateMonth;
echo '<br/>';


// subtract 1 year to current date..
$newDateYear = date('Y-m-d',strtotime('-1 year',$date));
echo $newDateYear;
echo '<br/>';


?>