Jump to content

comparing 2 time stamp dates


jenny kaur

Recommended Posts

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!
Link to comment
Share on other sites

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]


cheers
Mark
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.