Reputation: 1280
I am using strtotime
function to convert date to timestamp like
echo strtotime('4-5-2013');
its give result 1367618400. which is right. my problem is what if , if the date is in format mm-dd-yyyy instead of dd-mm-yyyy. for example same date is in 5-april instead of 4-may.
Upvotes: 0
Views: 137
Reputation: 11853
As per your latest comment
you can use
echo date("M-d-Y", mktime(0, 0, 0, 12, 31, 1997));
to pass any format and use mktime function.
Upvotes: 1
Reputation: 6950
strtotime treats strings with -
in them as dd-mm-yyyy
and /
as mm/dd/yyyy
.
4-5-2013
will be 4-may
4/5/2013
will be 5 apr
Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.
REF: http://php.net/manual/en/function.strtotime.php
Upvotes: 4
Reputation: 11984
echo strtotime('5-4-2013');//Oupt puts 1367650800
echo strtotime('4-5-2013');//Oupt puts 1367618400
Upvotes: 0