php date get month code example

Example 1: php get day from date

$timestamp = strtotime('2009-10-22');

$day = date('D', $timestamp);
var_dump($day);

Example 2: php grab month from date

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

Example 3: get current month php

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

Example 4: php check weekday of date

$dayofweek = date('w', strtotime($date));
$result    = date('Y-m-d', strtotime(($day - $dayofweek).' day', strtotime($date)));

Example 5: 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']));