MA

I use a JavaScript popup calendar which outputs the result into a textbox, the next step is to post to get the date selected.

For example, if i select 2007-11-05 from the calendar how can i find the day of the week?

For example 2007-11-05 is on Monday.

add a comment
0

5 Answers

  • Votes
  • Oldest
  • Latest
NE

I haven't had the time, nor access to the facilities to test this at the moment, but from what I can see it should work without any problems...

$date = '2007/10/31'; 
$weekday = date('l', strtotime($date)); // note: first arg to date() is lower-case L
echo $weekday; // SHOULD display Wednesday

The script is not dependant on the input structure of the date, providing it is valid, so you can customize it to your needs.

add a comment
0
BO

I haven't had the time, nor access to the facilities to test this at the moment, but from what I can see it should work without any problems...

$date = '2007/10/31'; 
$weekday = date('l', strtotime($date)); // note: first arg to date() is lower-case L
echo $weekday; // SHOULD display Wednesday

The script is not dependant on the input structure of the date, providing it is valid, so you can customize it to your needs.

That displays Wednesday for every date.

add a comment
0
MA
echo date('l', strtotim($date)); 

Thanks guys.

add a comment
0
AB

to all

guys thanks for your help.

I have faced the same problem and you have helped me

I want to edit to what you have wrote instead of using the method strtotim($date)) which change the string to date for those who use a date varible, they don't need to use the method strtotim(),just past the date variable alone

so the end result will be like this
echo date('l', $date));

now you will get the date names

add a comment
0
JO
<?php

// Create a new instance
$today = new DateTime('2015-11-05');

// Look a year into the future for example sake
$today->modify('+1 year 12 days');

// Display full day name
echo $today->format('l') . PHP_EOL; // lowercase L

// Display three-letter day name
echo $today->format('D') . PHP_EOL;

?>
joebert@frankenstien:~/Desktop$ php -f _.php 
Thursday
Thu
joebert@frankenstien:~/Desktop$
add a comment
0