[英]How to convert month number to month name in php
Is there a function in php wherein you can convert the number 12 to its equivalent in a month. PHP中是否有一个函数,您可以在一个月内将数字12转换为其等效值。 For example if the mysql database stores digits and not words for dates.
例如,如果mysql数据库存储的是数字而不是单词的日期。 how do you convert the number 12 into the word december?
您如何将数字12转换为12月这个词?
尝试此操作,并查看日期函数以获取更多答案:
date('F', mktime(0, 0, 0, 12))
您可以这样做:
echo date('F', mktime(0, 0, 0, 12));
strftime("%B", mktime(0, 0, 0, 12));
就像date()一样,除了如果您事先使用setlocale设置语言环境,它将为您进行本地化。
You could also do that directly in MySQL with 您也可以直接在MySQL中使用
SELECT MONTHNAME(STR_TO_DATE(12, '%m')); -- December
See http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_str-to-date 参见http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_str-to-date
date("F", mktime(0, 0, 0, 12, 1, 2000));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.