From ef151ba6c17e0741f99fdbfa834c3f8b34963aec Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Tue, 9 Nov 2010 10:53:51 +0000 Subject: [PATCH] Removed the reference to "US English" in the strtotime() description, since that's not true for all delimiters, and added an explanatory note summarising the Date and Time Formats grammar and how it pertains to m/d/y and d-m-y, along with a recommendation to use ISO 8601 or DateTime::createFromFormat() where possible. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@305220 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/datetime/functions/strtotime.xml | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/reference/datetime/functions/strtotime.xml b/reference/datetime/functions/strtotime.xml index 15ae18be4c..118533fc10 100644 --- a/reference/datetime/functions/strtotime.xml +++ b/reference/datetime/functions/strtotime.xml @@ -14,11 +14,11 @@ intnow - The function expects to be given a string containing a US English date - format and will try to parse that format into a Unix timestamp (the - number of seconds since January 1 1970 00:00:00 UTC), relative - to the timestamp given in now, or the current time - if now is not supplied. + The function expects to be given a string containing an English date format + and will try to parse that format into a Unix timestamp (the number of + seconds since January 1 1970 00:00:00 UTC), relative to the timestamp given + in now, or the current time if + now is not supplied. This function will use the TZ environment variable (if @@ -199,12 +199,28 @@ if (($timestamp = strtotime($str)) === false) { newer versions overcome this limitation though. + + + 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. + + + To avoid potential ambiguity, it's best to use ISO 8601 + (YYYY-MM-DD) dates or + DateTime::createFromFormat when possible. + + &reftitle.seealso; + DateTime::createFromFormat strptime