jenny kaur Posted March 21, 2006 Share Posted March 21, 2006 i need to know how to display a message if a certain day "2006-05-28" is in a date range input via a html form.[code]$start_date="2006-05-20";$end_date="2006-05-29";$start = strtotime("$start_date"); $end = strtotime("$end_date"); [/code]how would i display a message in the case above, i.e, your date selection includes "2006-05-28" which is a special day!however if the date is from 2006-05-29 to 2006-05-30, there should be no message. only if the date range features the 28th!please help,cheers! Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted March 21, 2006 Share Posted March 21, 2006 you're on the right track. now you just need to compare the date with the range.[code]$special_date = "2006-05-28";$start_date="2006-05-20";$end_date="2006-05-29";$start = strtotime("$start_date"); $end = strtotime("$end_date"); $special = strtotime($special_date);if ($special>=$start && $special<=$end){ echo 'thats a special date!';}[/code]cheersMark Quote Link to comment Share on other sites More sharing options...
Barand Posted March 21, 2006 Share Posted March 21, 2006 It will also work without the strtotime conversions[code]$special_date = "2006-05-28";$start_date="2006-05-20";$end_date="2006-05-29";if ($special_date>=$start_date && $special_date<=$end_date){ echo 'thats a special date!';}[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.