Format date in PHP English and Spanish?

2

I have this code PHP to format the dates coming from 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 English and Spanish , how could I do it?

    
asked by anonymous 25.07.2017 / 22:06

1 answer

3

Just follow the same line, putting the parameters according to the region, for example:

Spanish:

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:

25.07.2017 / 22:43