geej
geej

Reputation: 335

validate time field entry

is there any easy to validate a time field entry against the current date and time?i get date and time entry from an user in two separate fields. I used jquery date picker and time picker for both. with the date I had the option to show current date and future dates and not the past dates so it's good. with the time field i have to show all the time but want to somehow validate to see if the time is already gone for that date.I can o away from jquery and just use php if possible. any ideas?g

Upvotes: 0

Views: 593

Answers (1)

Artefacto
Artefacto

Reputation: 97805

You can do

$ispast = strotime($field_value) < time();

This will tell if the given time is in the past. The only requirement is that $field_value is in a format that strtotime recognizes. This will interpret the date in the default timezone you have set (see date_default_timezone_set).

Upvotes: 2

Related Questions