简体   繁体   中英

How to convert month number to name between date and year in php?

$dates = '2019-11-15 11:25:12';    
$date = date('d-m-Y', strtotime($dates));

current output: 15-11-2019

expected output: 15-Nov-2019

In this code I am have datetime and I want to change month number to name between date and year. So, How can I do this? Please help me.

Thank You

You just have to change the date format from 'dm-Y' to 'dM-Y' . All date format letters are explained here for future reference: https://www.adminschoice.com/php-date-format

You could try to change format string:

$dates = '2019-11-15 11:25:12';    
$date = date('d-M-Y', strtotime($dates));
echo $date;

Use uppercase M or F for month M is the first three letter while F is full name of the month

$date = date('d-M-Y', strtotime($dates));

or

$date = date('d-F-Y', strtotime($dates));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM