Reputation: 15
I'm getting the output of:
Warning: strtotime() expects parameter 2 to be long, string given in C:\xampp\htdocs\MindWeather\Assimilation\foreca_hourly.php on line 17
Today is 2014117, Tomorrow is 1970101
My code is:
$TodayIs = date('Ynd');
$nextdate = date('Ynd', strtotime($TodayIs,'+ 1 day'));
echo "<br><br> Today is $TodayIs, Tomorrow is $nextdate<br><br>";
I really don't expect to get a 1970-answer. It's supposed to display "Today is 2014117, Tomorrow is 2014118" instead of "Today is 2014117, Tomorrow is 1970101"
Upvotes: 0
Views: 154
Reputation: 2852
Try this:
$date = '2013-10-15';
$new_time = strtotime('+1 day', strtotime($date));
echo date('d-m-Y', $new_time); //displays 2013-10-16
Upvotes: 0
Reputation: 16086
Try like this:
$TodayIs = date('Ynd');
$nextdate = date('Ynd', strtotime('+ 1 day'));
echo "<br><br> Today is $TodayIs, Tomorrow is $nextdate<br><br>";
PHPfiddle link: http://phpfiddle.org/lite/code/bnf-scw
Upvotes: 0
Reputation: 68526
Why don't you make use of a DateTime
Class ?
<?php
$date = new DateTime();
echo "Today is ".$date->format('Y/m/d');
$date->add(new DateInterval('P1D'));
echo "<br>Tomorrow is ".$date->format('Y/m/d');
OUTPUT :
Today is 2014/01/17
Tomorrow is 2014/01/18
Upvotes: 0
Reputation: 272256
The second parameter to strtotime defaults to current time. So the following should produce desired result:
$nextdate = date('Ynd', strtotime('+1 day'));
// Today is 2014117, Tomorrow is 2014118
Upvotes: 2