2011-09-28, 04:35 AM
While working on a plugin, I have found that the built-in date formats are not always valid.
When using a "." or "-" as a separator, the format should always be day then month.
However, the built-in date format selections available to users allow for the reverse of month then day, which does not match standards, at least as PHP's strtotime() function assumes.
Examples:
I think that the bad formats should be removed in the next update. A simple mapping during upgrade script could be used to correct the formats.
In init.php the $date_formats array should change keys 1-4 (where month is before day) to a single entry with "/", which strtotime() understands
To maintain any existing plugins compatibility, you could just remove keys 2-4 and change key 1 to m/d/y and during upgrade just run a query to change dateformat field in the user's table to 1 where in (2,3,4). Since it is an associative array, nothing should break.
When using a "." or "-" as a separator, the format should always be day then month.
However, the built-in date format selections available to users allow for the reverse of month then day, which does not match standards, at least as PHP's strtotime() function assumes.
Examples:
strtotime(27.09.2011 08:55PM) = 1317182100
strtotime(27-09-2011 08:55PM) = 1317182100
strtotime(09.27.2011 08:55PM) = FAIL
strtotime(09-27-2011 08:55PM) = FAIL
I think that the bad formats should be removed in the next update. A simple mapping during upgrade script could be used to correct the formats.
In init.php the $date_formats array should change keys 1-4 (where month is before day) to a single entry with "/", which strtotime() understands
strtotime(09/27/2011 08:55PM) = 1317182100
To maintain any existing plugins compatibility, you could just remove keys 2-4 and change key 1 to m/d/y and during upgrade just run a query to change dateformat field in the user's table to 1 where in (2,3,4). Since it is an associative array, nothing should break.