Dynadot โ€” .com Transfer

Help please with this date calculation stuff in PHP

NamecheapNamecheap
Watch
Impact
111
Hi,

Let's say I have date format in PHP:

$date = date("Y-m-d");

How can I add exactly 1 year to this?

Thanks,
-Matt
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
i think u can use $date++ [not so sure tho since i m a newbie too]
 
0
•••
Can could just do this:

$year = date('Y');
$year++;

$remainingDate = date('m-d');
$date = "$year-$remainingDate";

-Bob
 
1
•••
i told him how over instant message ;)

PHP:
$date = date("Y-m-d");
$tmp = explode("-", $date);
$tmp[0]++;
$newdate = "$tmp[0]-$tmp[1]-$tmp[2]";
 
1
•••
Hm, thanks for the way you showed me axilant :) However, moondog's way is a bit shorter. I'll add to both your reps :)

Thanks both! ^_^
 
0
•••
Rep added for axilant..I alwayz got lost wid the explode thing in php...but ur example explains it a lil better :P thanks lol
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back