-1

I have a function which defines what day of the week the month starts on for the current month:

public function firstDayOfMonth()
    {
        $day =  (int) date("w", strtotime(date('m').'/01/'.date('Y').' 00:00:00'));
        return $day;
    }

How would I alter the above, in a way that allows me to get the day of the week the month starts on if I give it input, for example 'June'.

RSM
  • 14,540
  • 34
  • 97
  • 144
  • 1
    possible duplicate of [How to find a start date & end date of any given year & month](http://stackoverflow.com/questions/7184953/how-to-find-a-start-date-end-date-of-any-given-year-month) - Please use this site search, there are tons of data questions, most of them answered correctly. I doubt your scenario hasn't been handled out there. – hakre May 09 '12 at 13:32

2 Answers2

2

You can simplify your code to this:

$month = 'June';
$day = (int) date('w', strtotime($month));
abhay440
  • 146
  • 4
0
public function firstDayOfMonth($month) {
    $day =  (int) date("w", strtotime($month . ' 01,' . date('Y') . ' 00:00:00'));
    return $day;
}
Jim D
  • 988
  • 10
  • 18