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.
Try
<?php echo date('F', time());?>
In your question you are using $month=date("M",strtotime($arr2));
.
Use time($arr2)
instead of strtotime($arr2)
"F" returns the full name of month
<?php echo date('F'); ?>
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()
.
You could use date function directly in php try something like this
echo date("F");
U can Try this below function
date('F');