Reputation: 1197
I am getting wrong output i.e. 1194908400
None of this is working i.e. I tried to put double quotes around variable, tried without quotation marks. result is same and wrong.
$d='07-11-13';
echo $d;
echo strtotime($d);
echo "<br>";
echo strtotime("$d");
Upvotes: 0
Views: 201
Reputation: 10447
The problem is you need to specify a 4 digit year, so that strtime can fully work out which date format you are using. With 07-11-13
it probably thinks you are using 2007-11-13
.
Change it to 07-11-2013
and you will get the correct answer.
Upvotes: 0
Reputation: 7446
After a few checks, the error is actually NOT in the format you're passing, but rather on the way you're passing it.
What you should do is just replace "13" with "2013":
strtotime("07-11-2013");
output: 1383778800
echo strtotime("2013-11-07");
output: 1383778800
echo strtotime('07-11-13');
output: 1194908400
Upvotes: 1
Reputation: 78994
strtotime() will accept:
m/d/y
d-m-y
With / it expects month/day and with - it expects day-month.
Upvotes: 0
Reputation: 672
$d='07-11-13' is wrong, Try this
$d='2013-11-13';
echo $d;
echo strtotime($d);
echo "<br>";
echo strtotime("$d")
Upvotes: 0