4
I bought some systems but all come with date fields in English, and also in American standard: year/month/day.
How do I convert to day/month/year format?
4
I bought some systems but all come with date fields in English, and also in American standard: year/month/day.
How do I convert to day/month/year format?
12
<?php
echo date('Y/m/d'); // retorna a data nesse formato ano/mês/dia, essa data é a atual do servidor você pode alterar da forma que desejar exemplo date('d-m-Y')
echo date('d/m/Y', strtotime($variavel)); // convert a data da $variavel para o formato dia/mês/ano
?>
I advise you to use notepadd++ or Dreamweaver the resource to search in the files, so you search where you have date, date, $date something like that until you find and use the second option that Convert to our most common format
3
You can use a set of functions as follows:
Moving from American format to Brazilian format:
implode('/', array_reverse(explode('-', $data)));
E Changing from Brazilian format to American format:
implode('-', array_reverse(explode('/', $data)));
Links:
explode(): http://php.net/manual/en/function.explode.php
implode(): http://php.net/manual/en/function.implode.php
array_reverse(): http://php.net/manual/en/function.array-reverse.php
3
Maybe you can use the locale
.
Take an example:
<?php
/* Define o local para Holandês(usar pt_BR para o Português(Brasil) ) */
setlocale (LC_ALL, 'nl_NL');
/* Mostra: vrijdag 22 december 1978 */
echo strftime ("%A %e %B %Y", mktime (0, 0, 0, 12, 22, 1978));
/* Tenta diferentes nomes de local para o Alemão apartir do PHP 4.3.0 */
$loc_de = setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
echo "Preferred locale for german on this system is '$loc_de'";
?>
References:
1
To convert dates from any format that date, you can use the native PHP Datetime class.
Take an example:
<?php
$data = '2014/07/17';
$data_brasil = DateTime::createFromFormat('Y/m/d', $data);
print_r($data_brasil->format('d/m/Y')); //17/07/2014
Browser other questions tagged php
You are not signed in. Login or sign up in order to post.
And this date is where? In the database? In the PHP file?
– Kazzkiq
Anthony, Welcome to Stackoverflow. You can explain your question better and be clearer on what you’re looking for. I understand you want to convert the date format but I have no idea where you want to do it...
– Sergio
If you can post the code and the database helps a lot, read the [Ask] tab and then [Edit] and your question.
– Olimon F.
He wants to convert the format in PHP, to reply is that the AP intends.
– Jorge B.
Be careful, if you have any connection to a database like Mysql, you should do all the Inserts in American format.
– ptkato