-2

I tried to get name of month in php:

$date = '2014-06-00';
echo $m = date('M', strtotime($date));

It gives me May month instead June.

PiligrimBilim
  • 107
  • 1
  • 1
  • 4

1 Answers1

0

This should work for you:

<?php

    $date = '2014-06-00';

    $monthNum  = substr($date, 5, 2);
    $dateObj   = DateTime::createFromFormat('!m', $monthNum);

    echo  $monthName = $dateObj->format('F');

?>

Output:

June
Rizier123
  • 58,877
  • 16
  • 101
  • 156