2
I have that code PHP
to format the date of a SQL
:
setlocale(LC_ALL, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese');
date_default_timezone_set('America/Sao_Paulo');
I also need to do to English and Spaniard, how could I do?
2
I have that code PHP
to format the date of a SQL
:
setlocale(LC_ALL, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese');
date_default_timezone_set('America/Sao_Paulo');
I also need to do to English and Spaniard, how could I do?
4
Just follow the same line, placing the parameters according to the region, example:
Spaniard:
setlocale(LC_ALL, 'es_ES', 'es_ES.utf-8', 'es_ES.utf-8', 'esp');
date_default_timezone_set('America/Argentina/Mendoza');
echo strftime("%A %d de %B del %Y");
Brazil
setlocale(LC_ALL, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese');
date_default_timezone_set('America/Sao_Paulo');
echo strftime("%A %d de %B de %Y");
USA
setlocale(LC_ALL, 'us', 'us.utf-8', 'us.utf-8');
date_default_timezone_set('America/Los_Angeles');
echo strftime("%A %d de %B of %Y");
Some answers that may contribute additional information:
References:
I couldn’t get it to work in Spanish. código
setlocale(LC_ALL, 'es_ES', 'es_ES.utf-8', 'es_ES.utf-8', 'esp'); date_default_timezone_set('America/Argentina/Mendoza'); echo strftime("%A %d of %B of %Y");
@Wagnermartinsbodyboard the 3 examples have been tested and are correct, which is that it did not work, as you are using?
I had to change my debian 8 configuration. Now it worked.
Browser other questions tagged php
You are not signed in. Login or sign up in order to post.
Have you read the documentation of these two functions? What you understand and what you don’t understand?
– Woss
You can create a function that asks the language as argument and returns the date in the desired format.
– rray
Available reading: http://www.learnaprogramar.com/index.php?option=com_content&view=arti&id=857:show-fecha-en-espanol-php-setlocale-strftime-formato-datedefault-Timezone-set-ejemplos-cu00831b&catid=70&Itemid=193
– novic
Soen - Spanish example: https://stackoverflow.com/questions/22635303/get-day-from-string-in-spanish-php
– novic