CodeIgniter Forums
add dates - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: add dates (/thread-13641.html)



add dates - El Forum - 12-01-2008

[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?


add dates - El Forum - 12-01-2008

[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.


add dates - El Forum - 12-01-2008

[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));


add dates - El Forum - 12-01-2008

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


add dates - El Forum - 12-01-2008

[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.