/** * Constructor required to power-up underlying {@link \CDateFormatter}. It * requires valid CLocale instance, which does not provide interface to * validate locale name, so the only way around is through exception. Since * ru/en won't cause an exception, this shouldn't slow down execution. */ public function __construct() { try { parent::__construct(\Yii::app()->language); } catch (CException $e) { parent::__construct('en'); } }
public function viewDate($date) { date_default_timezone_set('UTC'); $formater = new CDateFormatter(Yii::app()->locale); $hour = intval($formater->format('H', $date)); $min = intval($formater->format('mm', $date)); $sec = intval($formater->format('ss', $date)); $month = intval($formater->format('M', $date)); $day = intval($formater->format('d', $date)); $year = intval($formater->format('yyyy', $date)); return mktime($hour, $min, $sec, $month, $day, $year) * 1000; }
function sql2long_date($date) { $timestamp = CDateTimeParser::parse($date, 'yyyy-MM-dd'); $formater = new CDateFormatter('id_ID'); return $formater->formatDateTime($timestamp, 'long', false); }
<?php if ($this->beginCache('good-review-' . $review->id, array('duration' => 3600))) { ?> <?php $timestamp = CDateTimeParser::parse($review->date, 'yyyy-MM-dd'); $dateFormatter = new CDateFormatter('ru'); $date = $dateFormatter->format('d MMMM yyyy', $timestamp); $user = $review->user->username; ?> <div class="b-grade comment left0"> <div class="data"> <div class="grade-title"> <div class="user"> <span class="b-user"><b class="b-user"><?php echo $user; ?> </b></span> </div> <div class="date"><?php echo $date; ?> </div> <div class="clearfix"></div> </div> <div class="b-lr-container"> <div class="grade left"> <?php $r = $review->rating; echo '<div class="x-rating x-rate-' . round($r * 4) . '"></div>';
?> </th> <th><?php echo YiiDebug::t('Files'); ?> </th> <th><?php echo YiiDebug::t('Date create'); ?> </th> <th></th> </tr> </thead> <tbody> <?php $DF = new CDateFormatter(Yii::app()->sourceLanguage); $i = 0; foreach ($assets as $asset) { $i++; $path = $AM->getBasePath() . '/' . $asset; $files = CFileHelper::findFiles($path); $fileList = implode('<br />', $files); $blockAll = false; if (preg_match('|yii\\.debug\\.toolbar\\.js|is', $fileList)) { $blockAll = true; } ?> <tr class="<?php echo $i % 2 ? 'even' : 'odd'; ?>
/** * Add support for DateTime objects. * * @param string|DateTime $timestamp * @param string $dateWidth * @param string $timeWidth * * @return string */ public function formatDateTime($timestamp, $dateWidth = 'medium', $timeWidth = 'medium') { if ($timestamp instanceof \DateTime) { $timestamp = $timestamp->getTimestamp(); } return parent::formatDateTime($timestamp, $dateWidth, $timeWidth); }
public static function getFirstDayYear() { $cDateFormatter = new CDateFormatter(Yii::app()->language); $dayOfYear = $cDateFormatter->format("D", date('Y-m-d')); return date('Y-m-d', strtotime(date("Y-m-d") . " -" . $dayOfYear . "day")); }
public function dbDate() { $formater = new CDateFormatter(Yii::app()->locale); $this->date = $formater->format('yyyy-MM-dd HH:mm:ss', $this->date); }
public static function getDateFormatted($dateToFormat, $locale = null, $formatter = null) { if (strlen($dateToFormat) == 0) { return ""; } if ($locale == null) { $locale = CLocale::getInstance('en'); } if ($locale == null) { $locale = CLocale::getInstance(); } if ($formatter == null) { $formatter = new CDateFormatter($locale); } // var_dump($locale); // var_dump($formatter); return $formatter->format(User::getDateFormat($locale), $dateToFormat); }