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.

Link to comment
Share on other sites

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.

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.