Reputation: 1122
I need to create a function that takes month and year as parameters and returns the name of the day which was the 1st of the month.
For e.g. today is the 30th day of March 2012, how do I find out which day was the 1st? All I know is March 2012. Sorry for repeating, I just want to be clear.
Upvotes: 0
Views: 49
Reputation: 57316
Use the combination of strtotime
and date
functions:
$f_dt = strtotime("$month/01/$year");
$day = date('D', $f_dt);
Upvotes: 2
Reputation: 8916
Ack, totally misread... ok, instead that should be date('D',strtotime($year.'-'.$month.'-01'))
I assume by name of day you mean Monday, Tuesday, etc. Change the 'D' parameter there to 'l' (lowercase L) if you want the date written out instead of Mon, Tue, etc.
Upvotes: 1