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"
– Guilherme Nascimento
You can do the formatting in the query itself, giving the command
SELECT DATE_FORMAT(suaData, '%d-%m-%Y') FROM suaTabela
– adventistaam
@adventist this did not work, this function does not exist
– SM_S
date()
or classDateTime
are not affected by the locale.– rray
There is yes in mysql. Look here and here. Unless your field is not date type
– adventistaam
I am not using mysql
– SM_S
Then you should have set the tag on your question
– adventistaam