More information about this topic
Reset database
 | 
Select your language: English  Italian 
Date and time
  • Current language: en_us
  • Date & time short: 8/24/17 8:40:48 AM
  • Date medium: Aug 24, 2017
  • Time medium: 8:40:48 AM
  • Date short format: M/d/yy
  • Time medium format: h:mm:ss a
  • Parsed date and time: June 4, 2010
  • Date & time custom format: 08/24/2017 08:40:48

protected/modules/InternationalizationModule/views/datetime/basic.php


<ul>
<li>Current language: <?php echo Yii::app()->getLanguage(); ?></li>
<li>Date &amp; time short: <?php echo Yii::app()->dateFormatter->formatDateTime(time(), 'short'); ?></li>
<li>Date medium: <?php echo Yii::app()->dateFormatter->formatDateTime(time(), 'medium', false); ?></li>
<li>Time medium: <?php echo Yii::app()->dateFormatter->formatDateTime(time(), false, 'medium'); ?></li>
<li>Date short format: <?php echo Yii::app()->locale->getDateFormat('short'); ?></li>
<li>Time medium format: <?php echo Yii::app()->locale->getTimeFormat('medium'); ?></li>
<li>Parsed date and time: <?php echo Yii::app()->dateFormatter->format(Yii::app()->locale->getDateFormat('long'),
				CDateTimeParser::parse('04/06/2010', 'dd/MM/yyyy')); ?></li>
<li>Date &amp; time custom format: <?php echo Yii::app()->dateFormatter->formatDateTime(time(), 'small', 'small'); ?></li>
</ul>

protected/i18n/data/en_us.php

<?php
/**
 * Extends Locale data for 'en_US'.
 * In this file you can put custom locale settings that will be
 * merged with the ones provided by the framework
 * ( that are stored in <framework_dir>/i18n/data/ )
 */


return CMap::mergeArray(
	require(dirname($GLOBALS['yii']).'/i18n/data/'.basename(__FILE__)),
	array(
		'dateFormats' => array(
			'small'=>'MM/dd/yyyy',          // format used for input
			'calendar_small'=>'mm/dd/yy',   // format used for input with calendar widget
			'database'=>Yii::app()->params['database_format']['date'],
		),
		'timeFormats' => array(
			'small'=>'HH:mm:ss',          // format used for input
			'database'=>Yii::app()->params['database_format']['time'],
		)
	)
);

?>
Fork me on GitHub