本文整理汇总了PHP中QDateTime::SetDate方法的典型用法代码示例。如果您正苦于以下问题:PHP QDateTime::SetDate方法的具体用法?PHP QDateTime::SetDate怎么用?PHP QDateTime::SetDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDateTime
的用法示例。
在下文中一共展示了QDateTime::SetDate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ParsePostData
public function ParsePostData() {
$blnChanged = false;
$dttNewDateTime = new QDateTime();
// Update Date Component
switch ($this->strCalendarType) {
case QCalendarType::DateOnly:
case QCalendarType::DateTime:
case QCalendarType::DateTimeSeconds:
$strKey = $this->strControlId . "_intTimestamp";
if (array_key_exists($strKey, $_POST)) {
// If no date was set, set to null and return
$intTimestamp = $_POST[$strKey];
if (!$intTimestamp) {
$this->intTimestamp = null;
return;
}
// Otherwise, set up a new date object, and update dttNewDateTime accordingly
$blnChanged = true;
$dttSelectedDate = new QDateTime($_POST[$strKey]);
$dttNewDateTime->SetDate($dttSelectedDate->Year, $dttSelectedDate->Month, $dttSelectedDate->Day);
}
}
// Update Time Component
switch ($this->strCalendarType) {
case QCalendarType::TimeOnly:
case QCalendarType::TimeSecondsOnly:
case QCalendarType::DateTime:
case QCalendarType::DateTimeSeconds:
// Hour
$strKey = $this->strControlId . "_intHour";
if (array_key_exists($strKey, $_POST)) {
$blnChanged = true;
$dttNewDateTime->SetTime($_POST[$strKey], $dttNewDateTime->Minute, $dttNewDateTime->Second);
}
// Minute
$strKey = $this->strControlId . "_intMinute";
if (array_key_exists($strKey, $_POST)) {
$blnChanged = true;
$dttNewDateTime->SetTime($dttNewDateTime->Hour, $_POST[$strKey], $dttNewDateTime->Second);
}
// Second
$strKey = $this->strControlId . "_intSecond";
if (array_key_exists($strKey, $_POST)) {
$blnChanged = true;
$dttNewDateTime->SetTime($dttNewDateTime->Hour, $dttNewDateTime->Minute, $_POST[$strKey]);
}
}
// Update local intTimestamp
$this->intTimestamp = $dttNewDateTime->Timestamp;
}
示例2: FromTimeOnly
/**
* Constructs a new QDateTime as a time-only value. Uses default QDateTime constructor
* and simply nulls out the time value right afterward.
* @param mixed $mixValue
* @param DateTimeZone $objTimeZone
* @return QDateTime
*/
public static function FromTimeOnly($mixValue = null, DateTimeZone $objTimeZone = null)
{
$dttToReturn = new QDateTime($mixValue, $objTimeZone);
$dttToReturn->SetDate(null, null, null);
return $dttToReturn;
}