本文整理匯總了PHP中DatabaseCompatibilityUtil::getDateTimeFormat方法的典型用法代碼示例。如果您正苦於以下問題:PHP DatabaseCompatibilityUtil::getDateTimeFormat方法的具體用法?PHP DatabaseCompatibilityUtil::getDateTimeFormat怎麽用?PHP DatabaseCompatibilityUtil::getDateTimeFormat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DatabaseCompatibilityUtil
的用法示例。
在下文中一共展示了DatabaseCompatibilityUtil::getDateTimeFormat方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testConvertTimestampToDbFormatDateTimeAndBackToTimeStamp
public function testConvertTimestampToDbFormatDateTimeAndBackToTimeStamp()
{
$time = time();
$timeZone = date_default_timezone_get();
date_default_timezone_set('GMT');
$gmtDbFormatDateTime = Yii::app()->dateFormatter->format(DatabaseCompatibilityUtil::getDateTimeFormat(), $time);
date_default_timezone_set('America/New_York');
$dbFormatDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($time);
$timeStamp = DateTimeUtil::convertDbFormatDateTimeToTimestamp($dbFormatDateTime);
$this->assertEquals($gmtDbFormatDateTime, $dbFormatDateTime);
$this->assertEquals($time, $timeStamp);
date_default_timezone_set($timeZone);
}
示例2: testGetDateTimeFormat
public function testGetDateTimeFormat()
{
$this->assertEquals('yyyy-MM-dd HH:mm:ss', DatabaseCompatibilityUtil::getDateTimeFormat());
}
示例3: testDateTimeValidation
public function testDateTimeValidation()
{
$this->assertNotNull(CDateTimeParser::parse('2009-11-11 21:18:09', DatabaseCompatibilityUtil::getDateTimeFormat()));
$this->assertEmpty(CDateTimeParser::parse('ascascasc', DatabaseCompatibilityUtil::getDateTimeFormat()));
$this->assertEmpty(CDateTimeParser::parse(null, DatabaseCompatibilityUtil::getDateTimeFormat()));
}
示例4: convertTimestampToDbFormatDateTime
public static function convertTimestampToDbFormatDateTime($timestamp)
{
assert('is_int($timestamp)');
$timeZone = date_default_timezone_get();
date_default_timezone_set('GMT');
$result = Yii::app()->dateFormatter->format(DatabaseCompatibilityUtil::getDateTimeFormat(), $timestamp);
date_default_timezone_set($timeZone);
return $result;
}