本文整理汇总了PHP中QDateTime::qFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP QDateTime::qFormat方法的具体用法?PHP QDateTime::qFormat怎么用?PHP QDateTime::qFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDateTime
的用法示例。
在下文中一共展示了QDateTime::qFormat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __set
public function __set($strName, $mixValue)
{
switch ($strName) {
case 'MaxDate':
case 'Maximum':
try {
if (is_string($mixValue)) {
$mixValue = new QDateTime($mixValue);
}
parent::__set('MaxDate', QType::Cast($mixValue, QType::DateTime));
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
break;
case 'MinDate':
case 'Minimum':
try {
if (is_string($mixValue)) {
$mixValue = new QDateTime($mixValue);
}
parent::__set('MinDate', QType::Cast($mixValue, QType::DateTime));
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
break;
case 'DateTime':
try {
$this->dttDateTime = QType::Cast($mixValue, QType::DateTime);
if ($this->dttDateTime && $this->dttDateTime->IsNull()) {
$this->dttDateTime = null;
$this->blnModified = true;
}
if (!$this->dttDateTime || !$this->strDateTimeFormat) {
parent::__set('Text', '');
} else {
parent::__set('Text', $this->dttDateTime->qFormat($this->strDateTimeFormat));
}
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
break;
case 'JqDateFormat':
try {
parent::__set($strName, $mixValue);
$this->strDateTimeFormat = QCalendar::qcFrmt($this->JqDateFormat);
// trigger an update to reformat the text with the new format
$this->DateTime = $this->dttDateTime;
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
break;
case 'DateTimeFormat':
case 'DateFormat':
try {
$this->strDateTimeFormat = QType::Cast($mixValue, QType::String);
parent::__set('JqDateFormat', QCalendar::jqFrmt($this->strDateTimeFormat));
// trigger an update to reformat the text with the new format
$this->DateTime = $this->dttDateTime;
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
break;
case 'Text':
parent::__set($strName, $mixValue);
$this->dttDateTime = new QDateTime($this->strText);
break;
default:
try {
parent::__set($strName, $mixValue);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
break;
}
}
示例2: Objects
<input type="submit" id="double" name="double" value="Save 2 Objects (same Instance)"/></p>
<p>Using <strong>$blnForceUpdate</strong> to avoid the <strong>Optimistic Locking Exception</strong><br/>
<input type="submit" id="double_force" name="double_force" value="Force Update Second Object"/></p>
</form>
<?php
// Load the Two Person objects (same instance -- let them both be Person ID #4)
$objPerson1 = PersonWithLock::Load(5);
$objPerson2 = PersonWithLock::Load(5);
// Some RDBMS Vendors' TIMESTAMP is only precise to the second
// Let's force a delay to the next second to ensure timestamp functionality
// Note: on most web applications, because Optimistic Locking are more application user-
// level constraints instead of systematic ones, this delay is inherit with the web
// application paradigm. The following delay is just to simulate that paradigm.
$dttNow = new QDateTime(QDateTime::Now);
while ($objPerson1->SysTimestamp == $dttNow->qFormat(QDateTime::FormatIso)) {
$dttNow = new QDateTime(QDateTime::Now);
}
// Make Changes to the Object so that the Save Will Update Something
if ($objPerson1->FirstName == 'Al') {
$objPerson1->FirstName = 'Alfred';
$objPerson2->FirstName = 'Al';
} else {
$objPerson1->FirstName = 'Al';
$objPerson2->FirstName = 'Alfred';
}
switch (true) {
case array_key_exists('single', $_POST):
$objPerson1->Save();
_p('Person Id #' . $objPerson1->Id . ' saved. Name is now ' . $objPerson1->FirstName);
_p('.<br/>', false);
示例3: NowToString
public static function NowToString($strFormat = null)
{
$dttNow = new QDateTime(QDateTime::Now);
return $dttNow->qFormat($strFormat);
}
示例4: testFormat
public function testFormat()
{
$obj1 = new QDateTime("2002-3-5 13:15");
$this->assertEqual($obj1->qFormat("M/D/YY h:mm z"), "3/5/02 1:15 pm");
$this->assertEqual($obj1->qFormat("DDD MMM D YYYY"), "Tue Mar 5 2002");
$this->assertEqual($obj1->qFormat("One random DDDD in MMMM"), "One random Tuesday in March");
// Back compat
$this->assertEqual($obj1->qFormat("M/D/YY h:mm z"), $obj1->qFormat("M/D/YY h:mm z"));
}