• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
add dates

#1
[eluser]chinedubond[/eluser]
hello please i need some help in adding dates.
I have this date lets say 12/12/09 i want to make it 13/12/10.i.e add i year to it .
how do i do that in php?

#2
[eluser]featureBlend[/eluser]
Dude its not that difficult:

Code:
<?php
    $futuredate = strtotime("365 days");
    echo date("F d, Y", $futuredate);
?>

My suggestion to you before you post queries here would be to give it a teeney weeney bit of research....GL with translating the date to your preferred output format.

#3
[eluser]chinedubond[/eluser]
Thanks for ur elp but i got a solution

$expiryDate= date("d-m-Y",mktime(0, 0, 0, date("d",$date), date("m",$date), date("Y",$date)+1));

#4
[eluser]obiron2[/eluser]
29/02/2008??

#5
[eluser]xwero[/eluser]
[quote author="chinedubond" date="1228143866"]Thanks for ur elp but i got a solution

$expiryDate= date("d-m-Y",mktime(0, 0, 0, date("d",$date), date("m",$date), date("Y",$date)+1));[/quote]
If your date is a unix timestamp just do
Code:
// constants.php
define('YEAR_IN_SECONDS',31556926);
// somewhere in your code
$expiryDate= date("d-m-Y",$date+YEAR_IN_SECONDS);
unix timestamps are just numbers so date calculations should be calculations instead of function calls.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.