Regular Expressions 101

Community Patterns

Validate Date Represented by Integer 1900 - 2099


Regular Expression
PCRE (PHP <7.3)



Very simple validation expression that will validate a date in the range of 19000101 through 20991231. These formats are very popular for partitioning and representing dates as Long values or Integers. This does not check for Leap year values, or the months with varying number of days.

Please Note: this will return a match on 20220231 even though this is not a valid date. Additional validations should be used if Leap years and Days of the Month should be verified as well.

Submitted by Edward Rush - 2 years ago