validate_datetime

Validation of a date/time which checks if the string passed is a valid date and time. Allowed date formats

  • d-m-y 31-12-2014 separators can be a period, dash, forward slash, but not allow space
  • m-d-y 12-31-2014 separators can be a period, dash, forward slash, but not allow space
  • y-m-d 2014-12-31 separators can be a period, dash, forward slash, but not allow space
Parameters
string $value

The date/time string being checked

#
string $dateFormat = 'y-m-d'

The date format only to be validated against. Default is y-m-d for 2014-12-31.

#
string $timeFormat = 'both'

The time format: 12, 24 or both

#
Returns
bool

TRUE on success; FALSE on failure