本文整理汇总了PHP中QDateTime::setTime方法的典型用法代码示例。如果您正苦于以下问题:PHP QDateTime::setTime方法的具体用法?PHP QDateTime::setTime怎么用?PHP QDateTime::setTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDateTime
的用法示例。
在下文中一共展示了QDateTime::setTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ParsePostData
public function ParsePostData()
{
if (array_key_exists($this->strControlId . '_lstMonth', $_POST) || array_key_exists($this->strControlId . '_lstHour', $_POST)) {
$dttNewDateTime = new QDateTime();
// Update Date Component
switch ($this->strDateTimePickerType) {
case QDateTimePickerType::Date:
case QDateTimePickerType::DateTime:
case QDateTimePickerType::DateTimeSeconds:
$strKey = $this->strControlId . '_lstMonth';
if (array_key_exists($strKey, $_POST)) {
$intMonth = $_POST[$strKey];
} else {
$intMonth = null;
}
$strKey = $this->strControlId . '_lstDay';
if (array_key_exists($strKey, $_POST)) {
$intDay = $_POST[$strKey];
} else {
$intDay = null;
}
$strKey = $this->strControlId . '_lstYear';
if (array_key_exists($strKey, $_POST)) {
$intYear = $_POST[$strKey];
} else {
$intYear = null;
}
$this->intSelectedMonth = $intMonth;
$this->intSelectedDay = $intDay;
$this->intSelectedYear = $intYear;
if (strlen($intYear) && strlen($intMonth) && strlen($intDay)) {
$dttNewDateTime->setDate($intYear, $intMonth, $intDay);
} else {
$dttNewDateTime->Year = null;
}
break;
}
// Update Time Component
switch ($this->strDateTimePickerType) {
case QDateTimePickerType::Time:
case QDateTimePickerType::TimeSeconds:
case QDateTimePickerType::DateTime:
case QDateTimePickerType::DateTimeSeconds:
$strKey = $this->strControlId . '_lstHour';
if (array_key_exists($strKey, $_POST)) {
$intHour = $_POST[$strKey];
if (strlen($intHour)) {
$intHour = $_POST[$this->strControlId . '_lstHour'];
$intMinute = $_POST[$this->strControlId . '_lstMinute'];
$intSecond = 0;
if ($this->strDateTimePickerType == QDateTimePickerType::TimeSeconds || $this->strDateTimePickerType == QDateTimePickerType::DateTimeSeconds) {
$intSecond = $_POST[$this->strControlId . '_lstSecond'];
}
if (strlen($intHour) && strlen($intMinute) && strlen($intSecond)) {
$dttNewDateTime->setTime($intHour, $intMinute, $intSecond);
} else {
$dttNewDateTime->Hour = null;
}
}
}
break;
}
// Update local intTimestamp
$this->dttDateTime = $dttNewDateTime;
}
}
示例2: testTimeZoneIssues
public function testTimeZoneIssues()
{
$tz = new DateTimeZone('America/Los_Angeles');
$dt1 = new QDateTime('11/02/14', $tz);
// dst boundary date
$this->assertEquals('America/Los_Angeles', $dt1->getTimezone()->getName());
$dt2 = new QDateTime($dt1, null, QDateTime::DateOnlyType);
$this->assertEquals('America/Los_Angeles', $dt2->getTimezone()->getName());
$this->assertTrue($dt2->IsTimeNull());
$dt2->setTime(7, 0, 0);
$this->assertEquals(7, $dt2->Hour);
$this->assertEquals('America/Los_Angeles', $dt2->getTimezone()->getName());
// Test a specific PHP 'bug'. Not sure if it is a bug, or just a way things work.
$dt2 = new QDateTime($dt1->format(DateTime::ISO8601), null, QDateTime::DateOnlyType);
$dt2->setTime(7, 0, 0);
$this->assertEquals(7, $dt2->Hour);
$dt2 = new QDateTime('1/1/14', new DateTimeZone('America/Los_Angeles'));
$dt2->Timestamp = 1288486753;
$this->assertEquals('America/Los_Angeles', $dt2->getTimezone()->getName());
// make sure timezone isn't changed
$this->assertEquals(1288486753, $dt2->Timestamp);
// this isn't always true. If this is a dst boundary, it will not be true. Just making sure it is true when its supposed to be
}