• support@answerspoint.com

PHP, Date, Tutorials, Blog - Add or subs day, week, month, year in php Date

6277

PHP, Date, Tutorials, Blog - Add or subs day, week, month, year in php Date Function

<?php
$today=date('Y-m-d');    
echo "Today is ".$today;// show today

$timedate_after_5_day = strtotime(date("Y-m-d", strtotime($today)) . "+5 days"); // convert in time after 5 days
$date_after_5_day = date("Y-m-d",$timedate_after_5_day);//day after 5 days
echo "<br>After 5days from Today($today)  will be ".$date_after_5_day ;//show day after 5 days

$timedate_before_10_day = strtotime(date("Y-m-d", strtotime($today)) . "-10 days"); // convert in time before 10 days
$date_before_10_day = date("Y-m-d",$timedate_before_10_day);//day before 10 days
echo "<br>Before 10days from today($today) was ".$date_before_10_day;//show before 10 days

$timedate_after_3_week = strtotime(date("Y-m-d", strtotime($today)) . "+3 week"); // convert in time after 5 days
$date_after_3_week = date("Y-m-d",$timedate_after_3_week);//day after 3 week
echo "<br>After 3week from Today($today)  will be ".$date_after_3_week ;//show day after 3 week

$timedate_before_10_day = strtotime(date("Y-m-d", strtotime($today)) . "-8 week"); // convert in time before 8 week
$date_before_10_day = date("Y-m-d",$timedate_before_10_day);//day before 8 week
echo "<br>Before 8week from today($today) was ".$date_before_10_day;//show before 8 week

$timedate_after_2_month = strtotime(date("Y-m-d", strtotime($today)) . "+2 month"); // convert in time after 2 month
$date_after_2_month = date("Y-m-d",$timedate_after_2_month);//day after 2 month
echo "<br>After 2month from Today($today)  will be ".$date_after_2_month ;//show day after 2 month

$timedate_before_4_month = strtotime(date("Y-m-d", strtotime($today)) . "-4 months"); // convert in time before 4 month
$date_before_4_month = date("Y-m-d",$timedate_before_4_month);//day before 4 month
echo "<br>Before 4month from today($today) was ".$date_before_4_month;//show before 4 month

$timedate_after_9_year = strtotime(date("Y-m-d", strtotime($today)) . "+9 years"); // convert in time after 9 years
$date_after_9_year = date("Y-m-d",$timedate_after_9_year);//day after 3 week
echo "<br>After 9year from Today($today)  will be ".$date_after_9_year ;//show day after 9 year

$timedate_before_7_year = strtotime(date("Y-m-d", strtotime($today)) . "-7 years"); // convert in time before 7 years
$date_before_7_year = date("Y-m-d",$timedate_before_7_year);//day before 7 years
echo "<br>Before 7year from today($today) was ".$date_before_7_year;//show before 7 years
?>

 

0Answer


Your Answer

    Facebook Share        
       
  • asked 7 years ago
  • viewed 6277 times
  • active 7 years ago

Best Rated Questions