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 288 views
2 answers 344 views
1 answer 205 views
1 answer 218 views
1 answer 187 views
1 answer 186 views
2 answers 228 views
...