Skip to content

Instantly share code, notes, and snippets.

@Marian0
Created November 18, 2014 19:10
Show Gist options
  • Save Marian0/c28e33faf11b850edc2f to your computer and use it in GitHub Desktop.
Save Marian0/c28e33faf11b850edc2f to your computer and use it in GitHub Desktop.
Date format in Yii translatable applications
// 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