Use setlocale just for the date

0

I'm using setlocale so that php returns the name of the month in PT-BR. The problem is that it is affecting the system calculations. Php is putting a comma at the point link.

setlocale(LC_ALL, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese');
date_default_timezone_set('America/Sao_Paulo');

echo strftime('%b', strtotime("-1 month"));

echo "<br><br>";

echo 123.33 - 111.11;

In the example I posted it returns me:

Mai

12,22

Being that he has to return me:

Mai

12.22

How do I resolve this?

    
asked by anonymous 06.06.2017 / 14:49

1 answer

1

Following the comment / a> by Leandro Godoy Rosa, according to documentation , there are:

  • LC_ALL for all of the below
  • LC_COLLATE for string comparison, see strcoll ()
  • LC_CTYPE for character classification and conversion, for example strtoupper ()
  • LC_MONETARY for localeconv ()
  • LC_NUMERIC for decimal separator (See also localeconv ())
  • LC_TIME for date and time formatting with strftime ()
  • LC_MESSAGES for system responses (available if PHP was compiled with libintl)

That is, using LC_ALL will affect all items described, including LC_NUMERIC , which defines the formatting of numbers. If you want only the date setting to be affected, just change to LC_TIME :

setlocale(LC_TIME, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese');
    
06.06.2017 / 17:01