1
date_default_timezone_set('Asia/Calcutta');
        $date=date("d:m:Y");

Now `$date=14072015;

I want month name 'July' from this date function. i have tried this,but i got output January.

$arr1=explode(":",$date);
         $arr2=implode($arr1);
//         print_r($arr2);die;

//        print_r($arr1);die;



//        print_r($date);DIE;
        $year=date("Y");

        $month=date("M",strtotime($arr2));
        print_r($month);DIE;

I Want OUTPUT July.Please help.if anyother methods to solve this please help.

Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50
manjusha
  • 113
  • 4
  • 6
  • 15

5 Answers5

3

string date ( string $format [, int $timestamp = time() ] )

Returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given. In other words, timestamp is optional and defaults to the value of time().

Read php.net manual

Image

Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
1

Try

<?php echo date('F', time());?>

In your question you are using $month=date("M",strtotime($arr2));.

Use time($arr2) instead of strtotime($arr2)

DEMO

Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50
1

"F" returns the full name of month

 <?php echo date('F'); ?>
Maninderpreet Singh
  • 2,569
  • 2
  • 17
  • 31
0

You could use date function directly in php try something like this

echo date("F");
jameshwart lopez
  • 2,993
  • 6
  • 35
  • 65
0

U can Try this below function

date('F');