Reputation: 27038
i have a form and a input where i can place a date in this format m/d/y
<input type="text" name="date_ts" size=8 maxlength=8 value="">
i need to figure out a way of not letting the user input a date that is in the past.
any ideas? thanks
Upvotes: 0
Views: 107
Reputation: 5147
strtomtime()
is wonderful, use this date("m-d-Y", strtotime('now'))
to get in dd-mm-yyyy
format or any other suitable for your comparison, look at http://php.net/date for more date()
formatting optionsUpvotes: 0
Reputation: 102745
if (strtotime($_POST['date_ts']) < time()) // Past date was posted
Upvotes: 1
Reputation: 1629
You can convert the date to an Unix timestamp (strtotime()
and compare it with time();
(note: will not work with today)
Upvotes: 2