Created
November 18, 2014 19:10
-
-
Save Marian0/c28e33faf11b850edc2f to your computer and use it in GitHub Desktop.
Date format in Yii translatable applications
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In languages key value for example app_es.php | |
'yyyy-mm-dd' => 'dd/mm/yyyy', | |
'Y-m-d' => 'd/m/Y', | |
//In controller: | |
$date = DateTime::createFromFormat(Yii::t('app', 'Y-m-d') , $this->date); | |
$this->date = $date->format('Y-m-d'); | |
//Javascript to make datepicker (remember to ensure to be added datepicker.js and .css) | |
<script> | |
$(document).ready(function (){ | |
$("#MoneyInOut_date").datepicker({ | |
format: '<?php echo Yii::t('app','yyyy-mm-dd') ?>', | |
}) | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment