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.
- set the locale in the theme header.php file.
setlocale(LC_ALL, ‘es_ES.UTF8′); //at the very top of the theme header file. - 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.