How to get the month name from a date in PHP

3 Answers

0 votes
$date = new DateTime('2025-01-07');

$monthName = $date->format('F'); // 'F' gives the full month name

echo $monthName; 



/*
run:

January

*/

 



answered Jan 7, 2025 by avibootz
0 votes
$dateString = '2025-01-07';

$timestamp = strtotime($dateString);
$monthName = date('F', $timestamp); // 'F' gives the full month name

echo $monthName; 



/*
run:

January

*/

 



answered Jan 7, 2025 by avibootz
0 votes
$date = DateTime::createFromFormat('Y-m-d', '2025-01-07');

$monthName = $date->format('F'); // 'F' gives the full month name

echo $monthName; 



/*
run:

January

*/

 



answered Jan 7, 2025 by avibootz

Related questions

1 answer 196 views
2 answers 212 views
1 answer 109 views
1 answer 122 views
1 answer 102 views
1 answer 100 views
2 answers 99 views
...