changing timezone and locale for time in wordpress

In a recent project i had to change the time displayed in the wordpress posts to spanish language. I think there are other better ways than mine to change the time and locale in wordpress but what i came up with quickly was to set the locale to spanish and then use strftime function to change the time to spanish language.

  1. set the locale in the theme header.php file.
    setlocale(LC_ALL, ‘es_ES.UTF8′); //at the very top of the theme header file.
  2. using strftime function to change the time in the wordpress loop function.
    <?php echo strftime(“%A, %d”,strtotime(get_the_time(‘d M Y’)));?> de <?php echo strftime(“%B”,strtotime(get_the_time(‘d M Y’)));?> de <?php echo strftime(“%Y”, strtotime(get_the_time(‘d M Y’)));?>

This was how i set the locale for time to spanish in wordpress. if you have better ways out please comment.

This entry was posted in wordpress. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>