本文整理汇总了PHP中QDateTime类的典型用法代码示例。如果您正苦于以下问题:PHP QDateTime类的具体用法?PHP QDateTime怎么用?PHP QDateTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QDateTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetEndScript
public function GetEndScript()
{
$strToReturn = parent::GetEndScript();
if (QDateTime::$Translate) {
$strShortNameArray = array();
$strLongNameArray = array();
$strDayArray = array();
$dttMonth = new QDateTime('2000-01-01');
for ($intMonth = 1; $intMonth <= 12; $intMonth++) {
$dttMonth->Month = $intMonth;
$strShortNameArray[] = '"' . $dttMonth->ToString('MMM') . '"';
$strLongNameArray[] = '"' . $dttMonth->ToString('MMMM') . '"';
}
$dttDay = new QDateTime('Sunday');
for ($intDay = 1; $intDay <= 7; $intDay++) {
$strDay = $dttDay->ToString('DDD');
$strDay = html_entity_decode($strDay, ENT_COMPAT, QApplication::$EncodingType);
if (function_exists('mb_substr')) {
$strDay = mb_substr($strDay, 0, 2);
} else {
// Attempt to account for multibyte day -- may not work if the third character is multibyte
$strDay = substr($strDay, 0, strlen($strDay) - 1);
}
$strDay = QApplication::HtmlEntities($strDay);
$strDayArray[] = '"' . $strDay . '"';
$dttDay->Day++;
}
$strArrays = sprintf('new Array(new Array(%s), new Array(%s), new Array(%s))', implode(', ', $strLongNameArray), implode(', ', $strShortNameArray), implode(', ', $strDayArray));
$strToReturn .= sprintf('qc.regCAL("%s", "%s", "%s", "%s", %s); ', $this->strControlId, $this->dtxLinkedControl->ControlId, QApplication::Translate('Today'), QApplication::Translate('Cancel'), $strArrays);
} else {
$strToReturn .= sprintf('qc.regCAL("%s", "%s", "%s", "%s", null); ', $this->strControlId, $this->dtxLinkedControl->ControlId, QApplication::Translate('Today'), QApplication::Translate('Cancel'));
}
return $strToReturn;
}
示例2: dtgItems_Bind
public function dtgItems_Bind()
{
$intYear = QApplication::PathInfo(0);
$dttStart = new QDateTime($intYear . '-01-01');
$dttEnd = new QDateTime($dttStart);
$dttEnd->Year += 1;
$dttStart->SetTime(null, null, null);
$dttEnd->SetTime(null, null, null);
$objPersonCursor = Person::QueryCursor(QQ::AndCondition(QQ::GreaterOrEqual(QQN::Person()->StewardshipContribution->DateCredited, $dttStart), QQ::LessThan(QQN::Person()->StewardshipContribution->DateCredited, $dttEnd)), QQ::Clause(QQ::Distinct(), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName)));
$strNameArray = array();
$strNameValueArray = array();
while ($objPerson = Person::InstantiateCursor($objPersonCursor)) {
$strToken = strtolower($objPerson->FirstName . '|' . $objPerson->LastName);
$strToken = str_replace(' ', '', $strToken);
$strToken = str_replace('.', '', $strToken);
$strToken = str_replace(',', '', $strToken);
$strToken = str_replace('-', '', $strToken);
$strToken = str_replace('_', '', $strToken);
$strToken = str_replace('/', '', $strToken);
if (array_key_exists($strToken, $strNameArray)) {
$strNameValueArray[$strToken] = $objPerson->FirstName . ' ' . $objPerson->LastName;
}
$strNameArray[$strToken] = true;
}
$this->dtgItems->DataSource = $strNameValueArray;
}
示例3: Validate
/**
* Validate the control.
* @return bool
*/
public function Validate()
{
if (!parent::Validate()) {
return false;
}
if ($this->strText != '') {
$dttDateTime = new QDateTime($this->strText, null, QDateTime::DateOnlyType);
if ($dttDateTime->IsDateNull()) {
$this->ValidationError = QApplication::Translate("Invalid date");
return false;
}
if (!is_null($this->Minimum)) {
if ($dttDateTime->IsEarlierThan($this->Minimum)) {
if ($this->strMinDateErrorMsg) {
$this->ValidationError = $this->strMinDateErrorMsg;
} else {
$this->ValidationError = QApplication::Translate("Date is earlier than minimum allowed");
}
return false;
}
}
if (!is_null($this->Maximum)) {
if ($dttDateTime->IsLaterThan($this->Maximum)) {
if ($this->strMaxDateErrorMsg) {
$this->ValidationError = $this->strMaxDateErrorMsg;
} else {
$this->ValidationError = QApplication::Translate("Date is later than maximum allowed");
}
return false;
}
}
}
return true;
}
示例4: 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);
}
示例5: Q
public static function Q(QDateTime $objQDateTime)
{
if ($objQDateTime->IsTimeNull()) {
//error_log("NotNUll: " . sprintf("'%s'", $objQDateTime->__toString('YYYY-MM-DD')));
return $objQDateTime->__toString('YYYY-MM-DD');
} else {
//error_log("IS NULL: " . sprintf("'%s'", $objQDateTime->__toString(QDateTime::FormatIso)));
return $objQDateTime->__toString(QDateTime::FormatIso);
}
}
示例6: dtgItems_Bind
public function dtgItems_Bind()
{
$intYear = QApplication::PathInfo(0);
$dttStart = new QDateTime($intYear . '-01-01');
$dttEnd = new QDateTime($dttStart);
$dttEnd->Year += 1;
$dttStart->SetTime(null, null, null);
$dttEnd->SetTime(null, null, null);
$this->dtgItems->DataSource = Person::QueryArray(QQ::AndCondition(QQ::GreaterOrEqual(QQN::Person()->StewardshipContribution->DateCredited, $dttStart), QQ::LessThan(QQN::Person()->StewardshipContribution->DateCredited, $dttEnd), QQ::IsNull(QQN::Person()->PrimaryAddressText), QQ::IsNull(QQN::Person()->StewardshipAddressId)), QQ::Clause(QQ::Distinct(), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName)));
}
示例7: 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");
}
示例8: 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;
}
示例9: __get
public function __get($strName)
{
switch ($strName) {
case 'GeneratedDescription':
if ($this->strLocation || $this->dttDateStart || $this->dttDateEnd) {
$strToReturn = ', to be held';
if ($this->strLocation) {
$strToReturn .= ' at ' . $this->strLocation;
}
if ($this->dttDateStart && $this->dttDateEnd) {
$dttCompare1 = new QDateTime($this->dttDateStart);
$dttCompare2 = new QDateTime($this->dttDateEnd);
$dttCompare1->SetTime(null, null, null);
$dttCompare2->SetTime(null, null, null);
if ($dttCompare1->IsEqualTo($dttCompare2)) {
$strToReturn .= ' on ' . $this->dttDateStart->ToString('MMMM D YYYY');
$strToReturn .= ' from ' . $this->dttDateStart->ToString('h:mm z');
$strToReturn .= ' to ' . $this->dttDateEnd->ToString('h:mm z');
} else {
$strToReturn .= ' from ' . $this->dttDateStart->ToString('MMMM D');
$strToReturn .= ' to ' . $this->dttDateEnd->ToString('MMMM D YYYY');
}
} else {
if ($this->dttDateStart) {
$strToReturn .= ' on ' . $this->dttDateStart->ToString('MMMM D YYYY');
if ($this->dttDateStart->Hour || $this->dttDateStart->Minute) {
$strToReturn .= ' @ ' . $this->dttDateStart->ToString('h:mm z');
}
} else {
if ($this->dttDateEnd) {
$strToReturn .= ' until ' . $this->dttDateEnd->ToString('MMMM D YYYY');
if ($this->dttDateStart->Hour || $this->dttDateEnd->Minute) {
$strToReturn .= ' @ ' . $this->dttDateEnd->ToString('h:mm z');
}
}
}
}
return $strToReturn;
} else {
return null;
}
break;
default:
try {
return parent::__get($strName);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
}
}
示例10: GetReportYtdByFundForMonth
/**
* Returns an array of 2-item arrays, where each item has the following index:
* 0: stewardship_fund_id
* 1; total amount YTD
* for a given month
* @param QDateTime $dttMonth
* @return string[][]
*/
public static function GetReportYtdByFundForMonth(QDateTime $dttMonth)
{
$dttMonth->Day = 1;
$dttMonth->SetTime(null, null, null);
$dttNextMonth = new QDateTime($dttMonth);
$dttNextMonth->Month++;
$dttNextMonth->SetTime(null, null, null);
$dttMonth->Month = 1;
$objResult = StewardshipPostAmount::GetDatabase()->Query(sprintf("SELECT stewardship_fund_id, SUM(amount) AS sum_amount FROM stewardship_post_amount, stewardship_post, stewardship_batch WHERE\n\t\t\t\tstewardship_batch_id=stewardship_batch.id AND\n\t\t\t\tstewardship_post_id=stewardship_post.id AND date_credited >= '%s' AND date_credited < '%s' GROUP BY stewardship_fund_id ORDER BY SUM(amount) DESC;", $dttMonth->ToString('YYYY-MM-DD'), $dttNextMonth->ToString('YYYY-MM-DD')));
$strToReturn = array();
while ($objRow = $objResult->GetNextRow()) {
$strToReturn[] = array($objRow->GetColumn('stewardship_fund_id'), $objRow->GetColumn('sum_amount'));
}
return $strToReturn;
}
示例11: SetupPanel
protected function SetupPanel()
{
$this->mctPledge = StewardshipPledgeMetaControl::Create($this, $this->strUrlHashArgument, QMetaControlCreateType::CreateOnRecordNotFound);
if (!$this->mctPledge->EditMode) {
// Trying to create a NEW comment
$this->mctPledge->StewardshipPledge->DateStarted = QDateTime::Now();
$this->mctPledge->StewardshipPledge->Person = $this->objPerson;
$this->mctPledge->StewardshipPledge->FulfilledFlag = false;
$this->mctPledge->StewardshipPledge->ActiveFlag = true;
$this->btnSave->Text = 'Create';
} else {
$this->btnSave->Text = 'Update';
$this->btnDelete = new QLinkButton($this);
$this->btnDelete->Text = 'Delete';
$this->btnDelete->CssClass = 'delete';
$this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction('Are you SURE you want to DELETE this pledge?'));
$this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
$this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction());
}
// Create Controls
$this->lstStewardshipFund = $this->mctPledge->lstStewardshipFund_Create(null, QQ::All(), array(QQ::OrderBy(QQN::StewardshipFund()->Name)));
$this->calDateStarted = $this->mctPledge->calDateStarted_Create();
$this->calDateEnded = $this->mctPledge->calDateEnded_Create();
$this->txtPledgeAmount = $this->mctPledge->txtPledgeAmount_Create();
$this->chkActiveFlag = $this->mctPledge->chkActiveFlag_Create();
$this->chkActiveFlag->Text = 'Note: All fulfilled pledges automatically considred "inactive".';
$this->calDateStarted->MinimumYear = 2000;
$this->calDateStarted->MaximumYear = date('Y') + 10;
$this->calDateEnded->MinimumYear = 2000;
$this->calDateEnded->MaximumYear = date('Y') + 10;
}
示例12: Log
private static function Log($strMessage, $intPriority, $intProjectId = null, $intLanguageId = null, $intUserId = null)
{
if (SERVER_INSTANCE != 'dev' && $intPriority == NarroLog::PRIORITY_DEBUG) {
return true;
}
$objLogEntry = new NarroLog();
$objLogEntry->Date = QDateTime::Now();
$objLogEntry->Priority = $intPriority;
$objLogEntry->Message = $strMessage;
$objLogEntry->ProjectId = is_null($intProjectId) ? is_null(self::$intProjectId) ? null : self::$intProjectId : $intProjectId;
$objLogEntry->LanguageId = is_null($intLanguageId) ? is_null(self::$intLanguageId) ? null : self::$intLanguageId : $intLanguageId;
$objLogEntry->UserId = is_null($intUserId) ? is_null(self::$intUserId) ? null : self::$intUserId : $intUserId;
try {
$objLogEntry->Save();
} catch (Exception $objEx) {
error_log($objEx->getMessage() . $objEx->getTraceAsString());
}
if (QFirebug::getEnabled()) {
switch ($intPriority) {
case NarroLog::PRIORITY_INFO:
QFirebug::info($objLogEntry->Message . ' / ' . $objLogEntry->UserId . ' / ' . $objLogEntry->ProjectId . ' / ' . $objLogEntry->LanguageId);
break;
case NarroLog::PRIORITY_WARN:
QFirebug::warn($objLogEntry->Message . ' / ' . $objLogEntry->UserId . ' / ' . $objLogEntry->ProjectId . ' / ' . $objLogEntry->LanguageId);
break;
case NarroLog::PRIORITY_ERROR:
QFirebug::error($objLogEntry->Message . ' / ' . $objLogEntry->UserId . ' / ' . $objLogEntry->ProjectId . ' / ' . $objLogEntry->LanguageId);
break;
default:
QFirebug::log($objLogEntry->Message . ' / ' . $objLogEntry->UserId . ' / ' . $objLogEntry->ProjectId . ' / ' . $objLogEntry->LanguageId);
}
}
}
示例13: Log
/**
* This will log a message to the Qcodo Log. Location of the log file is defined in __QCODO_LOG__
*
* By default, this will log a "Normal" level log entry in the "default" Qcodo log file, which is
* located at __QCODO_LOG__/default.log.txt
*
* Either parameter can be overridden.
*
* @param string $strMessage
* @param integer $intLogLevel
* @param string $strLogModule
* @return void
*/
public static function Log($strMessage, $intLogLevel = QLogLevel::Normal, $strLogModule = 'default')
{
// Cancel out if log level is too low
if ($intLogLevel > self::$MinimumLogLevel) {
return;
}
// Setup Log Path
if (!defined('__QCODO_LOG__')) {
throw new QCallerException('__QCODO_LOG__ must be defined before running QLog::Log');
}
// Cancel out if log path is null
if (!__QCODO_LOG__) {
return;
}
// Create the Log Directory if it does NOT yet exist
if (!is_dir(__QCODO_LOG__)) {
QApplication::MakeDirectory(__QCODO_LOG__, 0777);
}
// Setup the Line
$strLine = sprintf("%5s | %s | %s | %s\r\n", getmypid(), QLogLevel::$NameArray[$intLogLevel], QDateTime::Now()->NowToString(QDateTime::FormatIso), self::FormatMessage($strMessage));
// Open the File for Writing
$strLogFilePath = __QCODO_LOG__ . '/' . $strLogModule . self::$Extension;
$objFile = fopen($strLogFilePath, 'a');
// Write the Line
fwrite($objFile, $strLine);
fclose($objFile);
}
示例14: btnOkay_Click
public function btnOkay_Click($strFormId, $strControlId, $strParameter)
{
$this->btnOkay->Enabled = true;
$blnNewTopic = false;
// Setup stuff if it's a NEW message being posted (either a NEW response or a NEW topic)
if (!$this->blnEditMode) {
// For NEW TOPIC in this Forum
if (!$this->mctMessage->Message->Topic) {
$objForum = Forum::Load($this->lstForum->SelectedValue);
$objNewTopic = $objForum->PostTopic(trim($this->txtTopicName->Text), trim($this->txtMessage->Text), QApplication::$Person);
QApplication::Redirect(sprintf('/forums/forum.php/%s/%s/', $objForum->Id, $objNewTopic->Id));
// Otherwise, it's a new POST in this TOPIC
} else {
$this->mctMessage->Message->PostDate = QDateTime::Now();
}
// Set the Reply Number for this New Message
$this->mctMessage->Message->ReplyNumber = $this->mctMessage->Message->Topic->GetNextReplyNumber();
}
// Save Everything Else
$this->mctMessage->SaveMessage();
$this->mctMessage->Message->RefreshCompiledHtml();
$this->mctMessage->SaveMessage();
// Refresh Stats and Stuff
$this->mctMessage->Message->Topic->RefreshStats();
$this->mctMessage->Message->Topic->RefreshSearchIndex();
$this->mctMessage->Message->TopicLink->RefreshStats();
// Send Alerts and Reset Read Flag on any NEW post
if (!$this->blnEditMode) {
$this->mctMessage->Message->SendAlerts();
$this->mctMessage->Message->Topic->UnassociateAllPeopleAsRead();
//Mark as read for poster
$this->mctMessage->Message->Topic->AssociatePersonAsRead(QApplication::$Person);
}
$this->ParentControl->CloseMessageDialog(true, !$this->blnEditMode);
}
示例15: Save
public function Save($blnForceInsert = false, $blnForceUpdate = false)
{
$this->intSuggestionWordCount = NarroString::WordCount($this->strSuggestionValue);
$this->intSuggestionCharCount = mb_strlen($this->strSuggestionValue);
$this->strSuggestionValueMd5 = md5($this->strSuggestionValue);
if (!isset($this->blnIsImported)) {
$this->blnIsImported = false;
}
if (!$this->__blnRestored || $blnForceInsert) {
$this->dttCreated = QDateTime::Now();
} else {
$this->dttModified = QDateTime::Now();
}
parent::Save($blnForceInsert, $blnForceUpdate);
/**
* Update all context infos with the has suggestion property
*/
$arrContextInfo = NarroContextInfo::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->TextId, $this->intTextId), QQ::Equal(QQN::NarroContextInfo()->LanguageId, $this->intLanguageId), QQ::Equal(QQN::NarroContextInfo()->HasSuggestions, 0)));
foreach ($arrContextInfo as $objOneContextInfo) {
$objOneContextInfo->HasSuggestions = 1;
$objOneContextInfo->Modified = QDateTime::Now();
try {
$objOneContextInfo->Save();
} catch (Exception $objEx) {
NarroLogger::LogWarn($objEx->getMessage());
}
}
}