Jump to content

Comparing a date to see what day it falls on???


elmas156

Recommended Posts

Hey everyone, I'm trying to take a specific date and check to see if it falls on a specific day of the week and use it in an if/else statement.  For example:

<?php
if ($date falls on a Saturday or Sunday) {

echo "I'm going to be at the lake on $date.  Please choose another date.";

} else {

echo "Your appointment has been scheduled.";

}
?>

Obviously, what I'm having problems with is checking to see if the date falls on a Saturday or Sunday.  Does anyone have any ideas on how I could accomplish this?  Thanks for your help.

I already know how to get the current date in the format that I need to use:

 

<?php
$cmonth=date("m");
$cday=date("d");
$cyear=date("Y");
$cdate=$cmonth  ."/".  $cday  ."/".  $cyear;
?>

 

But is there a way to tell if a selected date (not the current date) falls on a specific day of the week?

 

I already have the calendar/date selector in a form on the previous page (in this format: 09/05/2008).  When the form is submitted it sends the selected date to schedule.php.  I want to check to see if the selected date falls on a Saturday or Sunday.  If so, the user will be alerted that appointment dates are not accepted on Saturday or Sunday, otherwise it will go on with the code and insert the information into the database and schedule the appointment.  Thanks for any input.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.