php get month code example

Example 1: get current month php

current month
  //half name in words
  date('M');
//full name in words
date('F');
//number
date('m');

Example 2: php grab month from date

$month = date("m",strtotime($mydate));

Example 3: datetime get month php

$dateTime = new DateTime();
$month = $dateTime->format('m');

Example 4: get month from database php

echo 'Day' . date('d', strtotime($row['Date']));
echo 'Month' . date('m', strtotime($row['Date']));
echo 'Year' . date('Y', strtotime($row['Date']));

Example 5: get month days in php

echo cal_days_in_month(CAL_GREGORIAN, 8, 2009);