Jump to content

work out day of week from given date


ukweb

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);

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.