August 5th, 2013, 10:14 AM
PHP strtotime(), parsing order of date formats
I check for this on google, could not find a good guide in details about strtotime datestrings. The manual siad it uses the same Unix datetime formats but I could not find what i was looking for in docs for Unix as well.
My question is,
What is the order in which strtotime determines which format a given datetime string is in?
Let me elaborate.
Suppose my code says
I assume strotime() will first identify the date format used by comparing it with valid dateformats. What I want to know is the actual order of comparison. For eg. if the above example will be parsed as December 1st or January 12th.
Thanks in advance.
August 5th, 2013, 10:45 AM
so during your research, it never occured to you that it might be a good idea to look into the manual?
The various other formats can be found behind a link on the same page.
Originally Posted by the manual
Either way: Why on earth would you wanna rely on a default behaviour you couldn't even find out with a Google search? Isn't that a pretty clear warning sign that you should use an explicit format instead?
Comments on this post
August 18th, 2013, 02:14 PM
August 18th, 2013, 02:25 PM
No. You'd have to parse the custom date string yourself with a regex and then pass the year, month etc. to the Date constructor.
Originally Posted by Shefeer