I know I could write a simple if-then or switch statement to convert month numbers 1,2,3,etc to Jan, Feb, Mar... but I'm wondering if there is something built in to Drupal that I can take advantage of ro do this for me and save from duplicating code.

Thanks for any tips.

Comments

pobster’s picture

No need! PHP has something which does that automagically;

  $month = 8;
  print date("M", mktime(0, 0, 0, $month));

For reference, http://uk.php.net/date

Pobster

--------------------------------------------
http://www.justgiving.com/paulmaddern
--------------------------------------------

spanders’s picture

Forgot about the mktime function. Worked perfect, Thanks.

tomfallowfield’s picture

I find it gives random results unless you also specify the day of the month:

  $month = 8;
  print date("M", mktime(0, 0, 0, $month, 1));
idebr’s picture

Instead of date(), use format_date() to get the localized version, eg:

  $month = 8;
  print format_date(mktime(0, 0, 0, $month, 1), 'custom', 'M');