validate_time

Validation of a time which checks if the string passed is a valid time in 24-hour or 12-hour format or both Allowed inputs

  • 23:59 or 01:00 or 1:00
  • 23:59:59 or 01:00:00 or 1:00:00
  • 11:59am or 01:00pm or 1:00pm
  • 11:59 am or 01:00 pm or 1:00 PM or 1:00PM
  • 11:59:59am 01:00:00pm or 1:00:00pm
  • 11:59:59 AM 01:00:00 PM or 1:00:00PM
Parameters
string $value

The time string being checked

#
string $timeFormat = 'both'

The time format: 12, 24 or both

#
Returns
bool

TRUE on success; FALSE on failure