Kate Wintz
Kate Wintz

Reputation: 643

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. How fix it?

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

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

Upvotes: 0

Views: 3780

Answers (1)

zerkms
zerkms

Reputation: 254886

Based on your code:

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

strtotime() accepts date not just month

Upvotes: 3

Related Questions