Hello,
I need to calculate dates, e.g: if i have this date on string "12-07-2008" and I want to add to this date 17 month.
How can I calculate this date.
are the a func that do this calculate ? or I nedd to write it ?
Thank you
Hello,
I need to calculate dates, e.g: if i have this date on string "12-07-2008" and I want to add to this date 17 month.
How can I calculate this date.
are the a func that do this calculate ? or I nedd to write it ?
Thank you
As darkagn says, there are loads of ways in which you could do it. You could use strtotime, keep everything within date functions or do a simple explode and mktime:
$bits = explode("-",$date);
$newdate = date('d-m-Y',mktime(0,0,0,intval($bits[1]) + 17,$bits[0],$bits[2]));
//this approach has the advantage of correctly dealing with overflows( month + 17).
Thank you :)
I found strtotime func
ardav, thank you.
I used this code:
list($year,$month,$day) = explode("-",$row['prisonDate']);
$d = mktime(0,0,0,$month,$day,$year);
$dis = date("Y-m-d",strtotime("+".$discount ."months",$d));
And it's work fun
OK, we solved? link below the edit box.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.