2

I use the following code to display the date in my node template:

<?php echo date("j F Y", $created); ?>

But I need to display the months in a different language, how can I do that?

2 Answers 2

4

I think you should use format_date() function that allows you add you own format and Drupal will translate it into the currently website site language.

3
  • 2
    Or date_format_date() (the tags suggest the OP's using date.module).
    – Andy
    Oct 11, 2011 at 11:39
  • And what to do if we only want to translate the month and not the whole website? May 27, 2013 at 17:35
  • 1
    You can either use the t function or, format_date accept a langcode parameter that will translate your month if the language is activated in your web site.
    – yvan
    May 28, 2013 at 8:11
0

did you try ;-) Whatever the $language parameter, the format_date() function doesn't change (for me) the language of the date.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.