本文整理汇总了PHP中DateHelper::isEmptyDate方法的典型用法代码示例。如果您正苦于以下问题:PHP DateHelper::isEmptyDate方法的具体用法?PHP DateHelper::isEmptyDate怎么用?PHP DateHelper::isEmptyDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateHelper
的用法示例。
在下文中一共展示了DateHelper::isEmptyDate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: applyTimeZone
/**
* Converts a Date Time value into the user Timezone if it's different
* first convert to UTC then make timezone + daytime conversions
* @param timestamp $time : is the system timzone : must be a timestamp like strtotime or time
* @param php::timezone $tz is a Php timezone string. If not filled will use userPref or system TZ (if not loggedin) : http://php.net/manual/fr/timezones.php
*/
public static function applyTimeZone($time, $tz = null, $type = null)
{
$systemTZ = date_default_timezone_get();
//echo "<br/>xxxxxxx applyTimeZone input time : ".date("Y-m-d H:i:s", $time);
if (!$tz) {
$tz = UserPref::getValue(UserPref::PREF_USER_TIME_ZONE);
}
if (!DateHelper::isEmptyDate($time)) {
if (date_default_timezone_get() != $tz) {
//pass the time to UTC timezone
//date_default_timezone_set("UTC");
//$utcTime = date("Y-m-d H:i", $time);
//$utcTime = strtotime($utcTime);
//now tranform back to User timezone
/*Yii::app()->localtime->TimeZone = $tz;
$return = array('datetime' => Yii::app()->localtime->toLocalDateTime(date('Y-m-d H:i:s',$utcTime),'short','short'),
'date' => Yii::app()->localtime->toLocalDate(date('Y-m-d H:i:s',$utcTime),'short','short'),
'time' => Yii::app()->localtime->toLocalTime(date('Y-m-d H:i:s',$utcTime),'short','short'));*/
date_default_timezone_set($tz);
}
$return = array('datetime' => date(self::DATETIME_FORMAT, $time), 'date' => date("Y-m-d", $time), 'time' => date("H:i", $time), 'timestamp' => $time, 'iso8601' => date('Ymd', $time) . 'T' . date('His', $time) . ($tz == 'UTC' ? 'Z' : ''));
//echo "<br/>xxxxxxx applyTimeZone output time : ".$return['datetime'];
} else {
$return = null;
}
date_default_timezone_set($systemTZ);
return $type != null ? $return[$type] : $return;
}