I’m using a datetime picker and have set this to insert the datetime into a form field in the format: 19 Jul 2010 14:00
Now I want to use the CTypeValidator to validate this to type ‘datetime’, but I’m having difficulty specifying ‘datetimeFormat’. From the patterns mentioned on http://www.yiiframework.com/doc/api/CDateTimeParser it seems I may not be able to validate to that particular format.
So what other options do I have to perform this validation?
public function dateTimeCheck()
{
if(!preg_match("/(\d{2})\s([a-z]{3})\s(\d{4})\s(\d{2})<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/sad.gif' class='bbc_emoticon' alt=':(' />\d{2})/i", $this->start_datetime))
{
$this->addError('start_datetime', 'Start Date/Time must be in valid format');
}
}
If anyone has any better solutions please let me know!