0

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

Kate Wintz
  • 633
  • 2
  • 11
  • 24
  • this has already been asked :) http://stackoverflow.com/questions/2943292/convert-month-number-to-month-short-name and here http://stackoverflow.com/questions/4612012/php-convert-month-number-to-short-month-name – user690936 Jan 01 '12 at 07:26
  • this has already been asked http://stackoverflow.com/questions/2943292/convert-month-number-to-month-short-name – user690936 Jan 01 '12 at 07:26
  • this has already been asked http://stackoverflow.com/questions/2943292/convert-month-number-to-month-short-name http://stackoverflow.com/questions/4612012/php-convert-month-number-to-short-month-name – user690936 Jan 01 '12 at 07:27
  • @user690936: please don't stop! we didn't get it at the first time! – zerkms Jan 01 '12 at 09:41

1 Answers1

3

Based on your code:

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

strtotime() accepts date not just month

zerkms
  • 249,484
  • 69
  • 436
  • 539