简体   繁体   English

如何在 php 中将月份编号转换为日期和年份之间的名称?

[英]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' .您只需将日期格式从'dm-Y'更改为'dM-Y' All date format letters are explained here for future reference: https://www.adminschoice.com/php-date-format所有日期格式字母都在这里解释以供将来参考: 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使用大写 M 或 F 表示月份 M 是前三个字母,而 F 是月份的全名

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

or或者

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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