Jump to content

Recommended Posts

Hi,

 

I'm using a date picker to choose a date. the format of the date entered into the textbox is yy/mm/dd

 

From this how can I work out the day of the week from the entered date? I need this as the first day has to be a sat, and if it isnt my form will tell the user to choose a saturday.

 

Is there a simple way of doing this?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/56232-work-out-day-of-week-from-given-date/
Share on other sites

you could use date() with a format that gives the day of the week using the timestamp calculated from the input:

 

$timestamp = mktime(0, 0, 0, $input{3}.$input{4}, $input{6}.$input{7}, $input{0}.$input{1});
$day_of_week = date('D', $timestamp);

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.