It is an ISO date as far as I can tell. It does have one subtle issue though if you are sending this between servers - it contains no timezone data. As a result, it would always be assumed to be a time within the local timezone for the current server. This is a guess, but does it pass validation if you add a timezone offset? If you know for sure it is UTC, just append "Z", otherwise an offset such as -05:00 (the offset from UTC to EST). Remember, without a timezone offset, the date is only good for the server generating it.
Paddy
Pádraic Brady
http://blog.astrumfutura.comhttp://www.survivethedeepend.comOpenID Europe Foundation Irish Representative
________________________________
From: MrZogs <r.bruyn@iampro.nl>
To: fw-i18n@lists.zend.com
Sent: Mon, October 12, 2009 9:24:02 AM
Subject: [fw-i18n] Issue with ISO date validation
Hi all,
I’m having some issues with validating a date using Zend_Validate_Date and
was hoping if anyone could shed some light on the matter.
Situation is as follows:
1) Javascript application send a date (along with some other data) to server
2) Server needs to validate date before storing
The date being sent is formatted like:
2009-10-08T20:02:54
This is an ISO date as far as I can tell.. (please correct me if I’m wrong)
So I have a validator set up as follows:
$format = Zend_Date::ISO_8601;
$v = new Zend_Validate_Date(array('format' => $format));
Unfortunately,
$v->isValid($date);
Returns false
So I’ve been digging a bit and found that it fails in
Zend_Date::isDate
on line 4600 (latest trunk) where it fails to parse the input date with the
given format.
I figured out that this happens because when you specify ISO as format it
uses:
‘dd mm yy’
as token to parse the date. Which obviously fails since the provided date
has a different format.
Now I can easily solve my initial problem by using a different format to
check against. But I’m curious
why it behaves this way. Since (it think) one would expect that if you
provide an ISO date, and tell the
validator to validate against ISO, it should pass validation.
Or am I just missing something?
I’ve put a small snippet on pastebin with an example to illustrate my
problem.
http://pastebin.com/m17450dc1 http://pastebin.com/m17450dc1
regards,
Rocco Bruyn
--
View this message in context:
http://www.nabble.com/Issue-with-ISO-date-validation-tp25852083p25852083.htmlSent from the Zend I18N/Locale mailing list archive at Nabble.com.
-----
Pádraic Brady
Blog:
http://blog.astrumfutura.comFree Zend Framework Book:
http://www.survivethedeepend.comOpenID Europe Foundation - Irish Representative