本文整理汇总了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;
}