Is there a function to determine what the first day of a month is ( monday, tuesday, wensday)?
Thankyou!
Is there a function to determine what the first day of a month is ( monday, tuesday, wensday)?
Thankyou!
check: http://php.net/manual/function.date.php
you can get the day of the week by
date ( 'l' ); // "L" in no capital letters
then you have to get a timestamp of the first of the month by mktime(...)
so the whole statement would be like:
$monthToGetTheFirstOf=12; // for december
$year=2005;
date ( 'l', mktime ( 1,1,1, $monthToGetTheFirstOf, 1, $year ) );
This also works:
$dayOfWeek = date('l', strtotime('2005-12-01'));
Thanks for the replies!
I tried it like this:
$setmonth = "10";
$setyear = "2005";
$dayOfWeek = date('l', strtotime('$setyear-$setmonth-01'));
And it always output Wensday, however if i replace the variables with hard values:
$dayOfWeek = date('l', strtotime('2005-12-01'));
It works fine!
Too bad because I need to be able to use variables and i guess it doesn't like them? =(
Tried '' and "" but didn't have any luck
Got it to work guys, here is what i did:
$dayofweek = date ( 'l', mktime ( 1,1,1, $selectmonth, 1, $selectyear ) );
Thanks again for the excellent help!11
I tried your code, and just echo'd like this:
echo('$setyear-$setmonth-01');
and the output was:
$setyear-$setmonth-01
So, instead of:
$dayOfWeek = date('l', strtotime('$setyear-$setmonth-01'));
Try:
$dayOfWeek = date('l', strtotime($setyear .'-'. $setmonth .'-01'));
But, I'm glad you got it working. I just like strtotime() better than mktime(). No particular reason, except that it's easier to read.
Mark