Regular Expression to Validate Date Formats
Version: R72.1
Article ID: PC000048

Description
Summary
Format 1:
MM/DD/YY HH:MM AM/PM
Regular Expression:
^([0]\d|[1][0-2])\/([0-2]\d|[3][0-1])\/\d{2}(\s([0]\d|[1][0-2])(:[0-5]\d){1,2})*\s*([aApP][mM]{0,2})?$
Examples:
12/31/2002
12/31/2002 08:00
12/31/2002 08:00 AM
Format 2:
DD/MM/YYYY HH:MM AM/PM
Regular Expression:
^([0]\d|[1][0-2])\/([0-2]\d|[3][0-1])\/\d{4}(\s([0]\d|[1][0-2])(:[0-5]\d){1,2})*\s*([aApP][mM]{0,2})?$
Examples:
31/12/2002
31/12/2002 08:00
31/12/2002 08:00 AM
Format 3:
YYYY/MM/DD HH:MM:SS
Regular Expression:
^\d{4}\/([0]\d|[1][0-2])\/([0-2]\d|[3][0-1])(\s([0]\d|[1][0-2])(:[0-5]\d){1,2})*\s*([aApP][mM]{0,2})?$
Examples:
2002/02/03
2002/02/03 12:12:18