01/20/2011 = January 20, 2011
01/2011 = January 2011
Only these two formats should be allowed!
i.e. 01/01/01/2011 = ERROR!
PHP:
$date = '01/20/2011';
//$date = '01/2011';
if(........format test........)//01/20/2011
{
if(...validation...)
{
echo date('F j, Y', strtotime($date));
}
}
else//01/2011
{
if(...validation...)
{
echo date('F Y', .....);
}
}
Validation:
IF = 01/20/2011
- First part should only contain numbers 01-12
- Second part should only contain numbers 01-31
- Third part should consist of 4 numbers
IF = 01/2011
- First part should only contain numbers 01-12
- Second part should consist of 4 numbers
Would this work: