简体   繁体   English

如何将月份编号转换为月份简称?

[英]How is convert month number to month short name?

For example my month number is ( 3 = Mar) Or ( 2 = Feb), i tryed as following code, but it doesn't work. 例如,我的月数是( 3 = 3月)或( 2 = 2月),我尝试按以下代码进行操作,但它不起作用。 How fix it? 如何解决?

$month = 2; 
echo date('M', strtotime($month));

Demo: http://codepad.viper-7.com/ZKctjg 演示: http //codepad.viper-7.com/ZKctjg

Based on your code: 根据您的代码:

$month = 2; 
echo date('M', strtotime('2012-' . $month . '-01'));

strtotime() accepts date not just month strtotime()接受日期而不仅仅是月份

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

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