-2

Using PHP how i can do this

$today = date("m/d/y"); // showing today

Output 11/18/13 will be saved in mysql as start date

Okay so if i like to add to this start date 30 days ... 60 days ... 90 days or any number of days to be add to $today and results be still in format m/d/y

Example may explain more what i mean

$today = date("m/d/y"); // 11/18/13

then add 10 days so $expired should be $today + 10; in days and results should be 11/28/13

~ thanks

Reham Fahmy
  • 4,937
  • 15
  • 50
  • 71

3 Answers3

1

Use DateTime::add() (PHP 5.3)

<?php
$date = new DateTime('2000-01-01');
$date->add(new DateInterval('P10D'));
echo $date->format('Y-m-d') . "\n";
?>
Chris
  • 4,255
  • 7
  • 42
  • 83
1

Try something like this should work for you

<?php
$Date = date("m/d/y");
echo date('m/d/y', strtotime($Date. ' + 10 days'));

?>
praveen
  • 286
  • 1
  • 8
0

Use this code:

$today = date("m/d/y");
echo date('m/d/y', strtotime($today. ' +10 day'));

Out put will be 11/28/13 as you desiring.

Code Lღver
  • 15,573
  • 16
  • 56
  • 75