Reputation: 250
I have the following script to do some date operation:
function indate($leavedate){
if($leavedate){
$enddate=$leavedate[0]['LoppumisPvm'];//This prints 23 Apr
$endday=date('d',strtotime($enddate));//this prints 23
$endmonth=date('M',strtotime($enddate));// This prints Apr
$additional_days=$endday-15;// This prints 8
$end = strtotime(date("d M", strtotime("15 Jan")) . " +$additional_days days");
echo $end;
I am trying to get that the variable $end
That will add the number of additional days to a specific date (there given 15 Jan).. It prints 1358179200 instead..
Upvotes: 1
Views: 2182
Reputation: 5114
You have a mix-up with an additional strtotime call and some bad positioned parenthesis. Change your code to:
$end = date("d M", strtotime("15 Jan + {$additional_days} days"));
Upvotes: 1
Reputation: 464
You need to change:
$end = strtotime(date("d M", strtotime("15 Jan")) . " +$additional_days days");
To be:
$end = date("d M",strtotime(date("d M", strtotime("15 Jan")) . " +$additional_days days"));
Upvotes: 0