本文整理汇总了PHP中QDateTime::setDate方法的典型用法代码示例。如果您正苦于以下问题:PHP QDateTime::setDate方法的具体用法?PHP QDateTime::setDate怎么用?PHP QDateTime::setDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDateTime
的用法示例。
在下文中一共展示了QDateTime::setDate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testQueryCount
public function testQueryCount()
{
$someDate = new QDateTime();
$someDate->setDate(2006, 1, 1);
$intItemCount = Milestone::QueryCount(QQ::GreaterThan(QQN::Milestone()->Project->StartDate, $someDate), QQ::Distinct());
$this->assertEqual($intItemCount, 3);
$intItemCount2 = Milestone::QueryCount(QQ::GreaterThan(QQN::Milestone()->Project->StartDate, $someDate), QQ::Clause(QQ::Distinct(), QQ::Distinct()));
$this->assertEqual($intItemCount2, 3);
}
示例2: testSetProperties
public function testSetProperties()
{
$obj1 = new QDateTime();
$obj1->setDate(2002, 3, 15);
$obj2 = new QDateTime("2002-03-15");
$obj3 = new QDateTime("2002-03-15 13:15");
$obj4 = new QDateTime("2002-03-16");
$this->assertTrue($obj1->IsEqualTo($obj2));
$this->assertTrue($obj1->IsEqualTo($obj3));
// dates are the same!
$this->assertFalse($obj3->IsEqualTo($obj4));
// dates are different!
}
示例3: testQueryArray
public function testQueryArray()
{
$someDate = new QDateTime();
$someDate->setDate(2006, 1, 1);
$objItems = Milestone::QueryArray(QQ::GreaterThan(QQN::Milestone()->Project->StartDate, $someDate), QQ::OrderBy(QQN::Milestone()->Project->Name));
$this->assertEqual(sizeof($objItems), 3);
$this->assertEqual($objItems[0]->Name, "Milestone F");
$this->assertEqual($objItems[0]->Project->Name, "Blueman Industrial Site Architecture");
$this->assertEqual($objItems[1]->Name, "Milestone D");
$this->assertEqual($objItems[1]->Project->Name, "State College HR System");
$this->assertEqual($objItems[2]->Name, "Milestone E");
$this->assertEqual($objItems[2]->Project->Name, "State College HR System");
}
示例4: 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;
}
}
示例5: testSetProperties
public function testSetProperties()
{
$obj1 = new QDateTime();
$obj1->setDate(2002, 3, 15);
$this->assertTrue($obj1->IsTimeNull(), "Setting only a date after null constructor keeps time null");
$obj2 = new QDateTime("2002-03-15");
$obj3 = new QDateTime("2002-03-15 13:15");
$obj4 = new QDateTime("2002-03-16");
$this->assertTrue($obj1->IsEqualTo($obj2));
$this->assertTrue($obj1->IsEqualTo($obj3));
// dates are the same!
$this->assertFalse($obj3->IsEqualTo($obj4));
// dates are different!
$obj5 = new QDateTime('13:15:02', null, QDateTime::TimeOnlyType);
$this->assertTrue($obj5->IsDateNull(), "Setting only a date after null constructor keeps time null");
$obj6 = new QDateTime('2002-03-15 13:15:02');
$obj1->SetTime($obj5);
$this->assertFalse($obj1->IsTimeNull(), "Setting a time with object results in a change in null time status");
$this->assertTrue($obj1->IsEqualTo($obj6), "SetTime correctly combines date only and time only values");
}