Displaying date in incorrect language

Asked

Viewed 48 times

0

I already tried the following code on php and it didn’t work:

setlocale(LC_ALL, 'pt_BR.UTF-8', 'Portuguese_Brazil.1252');

My server apache is in a centos and is running php 7.

Is displaying a date that comes from the database in English: 01-SEP-2018 and the right is '01-09-2018'

I’ve used the function DateTime and resolve, but when it comes null, displays the current date.

Actually I should update the language packs of centos?

                               <?php

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

                                    $datapagamento = $ct['DATA'];
                             ?>

                              <tr>
                                <td><?php echo $datapagamento; ?></td>
                                <td>

The array $ct is filled with a return of a database sql.

  • Show the PHP code, maybe it is possible to solve in it directly without having to stay depending on settings related to "operating system"

  • You can do the formatting in the query itself, giving the command SELECT DATE_FORMAT(suaData, '%d-%m-%Y') FROM suaTabela

  • @adventist this did not work, this function does not exist

  • 1

    date() or class DateTime are not affected by the locale.

  • There is yes in mysql. Look here and here. Unless your field is not date type

  • I am not using mysql

  • Then you should have set the tag on your question

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.