1
I need an example of how to change the date to the Brazilian standard.
1
I need an example of how to change the date to the Brazilian standard.
3
You can use the following function:
Yii::$app->getFormatter()->asDate($variavel_para_formatacao)
Don’t forget to make the necessary settings in the file common/config/main.cfg
'components' => [
//...
'formatter' => [
'dateFormat' => 'dd/MM/yyyy',
'datetimeFormat' => 'dd/MM/yyy H:i',
'timeFormat' => 'H:i',
'decimalSeparator' => ',',
'thousandSeparator' => '.',
'currencyCode' => 'R$',
],
//....
-1
Try using the native function to own PHP:
$mode->sua_data = date('d-m-Y', strtotime($model->sua_data));
date
// Format a date for other formats
strtotime
// Turns a String into datetime (date)
Your date (probably taken from the database) will come as a normal string, so before using the date you need to turn it into datetime. If a normal string is passed to the date it will transform it into an ult date (01-01-1970).
Browser other questions tagged date yii
You are not signed in. Login or sign up in order to post.