当前位置: 首页>>代码示例>>PHP>>正文


PHP SS_Datetime::now方法代码示例

本文整理汇总了PHP中SS_Datetime::now方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_Datetime::now方法的具体用法?PHP SS_Datetime::now怎么用?PHP SS_Datetime::now使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SS_Datetime的用法示例。


在下文中一共展示了SS_Datetime::now方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 function index()
 {
     $posts = $this->request->postVars();
     $filename = $posts['filename'];
     $surveyID = intval($posts['surveyID']);
     if (!$filename || !Member::currentUser() || !$surveyID || !($Survey = Survey::get()->filter('ID', $surveyID)->first())) {
         return false;
     }
     $folder = Folder::find_or_make('jsonFormFiles');
     $fullFileName = Director::baseFolder() . '/' . $folder->getRelativePath() . $filename . '.json';
     $jsonString = '{"name":"' . $Survey->Name . '","startDate": "' . $Survey->StartDate . '", "endDate": "' . $Survey->EndDate . '","sections": [';
     foreach ($Survey->Sections() as $Section) {
         $jsonString .= '{"Title": "' . $Section->Title . '","Descripton": "' . $Section->Description . '","sectionQuestions": [';
         foreach ($Section->SurveyQuestions() as $SQ) {
             $jsonString .= '{"number": "' . $SQ->Number . '","title": "' . $SQ->Title . '","description":"' . $SQ->Description . '","helpText": "' . $SQ->HelpText . '","questions": [';
             foreach ($SQ->Questions() as $Question) {
                 $jsonString .= $Question->renderJson();
             }
             $jsonString = rtrim($jsonString, ",");
             $jsonString .= ']},';
         }
         $jsonString = rtrim($jsonString, ",");
         $jsonString .= ']},';
     }
     $jsonString = rtrim($jsonString, ",");
     $jsonString .= ']}';
     file_put_contents($fullFileName, $jsonString);
     $Survey->LastJsonGenerated = SS_Datetime::now()->getValue();
     $Survey->write();
 }
开发者ID:helpfulrobot,项目名称:cbarberis-silverstripe-surveys,代码行数:30,代码来源:JsonFileGenerator.php

示例2: check

 /**
  * @inheritdoc
  *
  * @return array
  */
 function check()
 {
     $cutoffTime = strtotime($this->relativeAge, SS_Datetime::now()->Format('U'));
     $files = $this->getFiles();
     $invalidFiles = array();
     $validFiles = array();
     $checkFn = $this->checkFn;
     $allValid = true;
     if ($files) {
         foreach ($files as $file) {
             $fileTime = $checkFn($file);
             $valid = $this->compareOperand == '>' ? $fileTime >= $cutoffTime : $fileTime <= $cutoffTime;
             if ($valid) {
                 $validFiles[] = $file;
             } else {
                 $invalidFiles[] = $file;
                 if ($this->checkType == self::CHECK_ALL) {
                     return array(EnvironmentCheck::ERROR, sprintf('File "%s" doesn\'t match age check (compare %s: %s, actual: %s)', $file, $this->compareOperand, date('c', $cutoffTime), date('c', $fileTime)));
                 }
             }
         }
     }
     // If at least one file was valid, count as passed
     if ($this->checkType == self::CHECK_SINGLE && count($invalidFiles) < count($files)) {
         return array(EnvironmentCheck::OK, '');
     } else {
         if (count($invalidFiles) == 0) {
             return array(EnvironmentCheck::OK, '');
         } else {
             return array(EnvironmentCheck::ERROR, sprintf('No files matched criteria (%s %s)', $this->compareOperand, date('c', $cutoffTime)));
         }
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-environmentcheck,代码行数:38,代码来源:FileAgeCheck.php

示例3: sendReceipt

 /**
  * Send customer an order receipt email.
  * Precondition: The order payment has been successful
  */
 public function sendReceipt()
 {
     $subject = sprintf(_t("OrderNotifier.RECEIPTSUBJECT", "Order #%d Receipt"), $this->order->Reference);
     $this->sendEmail('Order_ReceiptEmail', $subject, self::config()->bcc_receipt_to_admin);
     $this->order->ReceiptSent = SS_Datetime::now()->Rfc2822();
     $this->order->write();
 }
开发者ID:helpfulrobot,项目名称:silvershop-core,代码行数:11,代码来源:OrderEmailNotifier.php

示例4: getFormField

 /**
  * Return the form field
  *
  */
 public function getFormField()
 {
     $defaultValue = $this->DefaultToToday ? SS_Datetime::now()->Format('Y-m-d') : $this->Default;
     $field = EditableDateField_FormField::create($this->Name, $this->EscapedTitle, $defaultValue)->setConfig('showcalendar', true)->setFieldHolderTemplate('UserFormsField_holder')->setTemplate('UserFormsField');
     $this->doUpdateFormField($field);
     return $field;
 }
开发者ID:camfindlay,项目名称:silverstripe-userforms,代码行数:11,代码来源:EditableDateField.php

示例5: approve

 public function approve()
 {
     $this->Moderated = true;
     $this->IsApproved = true;
     $this->write();
     $parent = $this->getParent();
     //debug::show($parent->ClassName);
     if ($parent->GuestBookID) {
         $GuestBookPage = $parent->GuestBook();
         $oBlogParent = $GuestBookPage->Level(1);
         //$GuestBookPageChildClass = $this->getGuestBookPageChildClass($GuestBook);
         $GuestBook = new BlogPost();
         $GuestBook->Title = $this->Title;
         $GuestBook->AuthorNames = $this->Author;
         $GuestBook->Content = $this->Content;
         $GuestBook->PublishDate = SS_Datetime::now()->getValue();
         $GuestBook->ParentID = $oBlogParent->ID;
         $GuestBook->FeaturedImageID = $this->ImageID;
         $GuestBook->doPublish();
         $GuestBook->write();
         $GuestBook->doRestoreToStage();
         //$GuestBook->writeToStage("Stage", "Live");
         $this->GuestBookLinkingID = $GuestBook->ID;
         $GuestBook->ShowInMenus = true;
         $GuestBook->doPublish();
         $GuestBook->write();
         $GuestBook->doRestoreToStage();
     }
     $this->write();
     return 'Submission published';
 }
开发者ID:chitosystems,项目名称:blog-guestbook,代码行数:31,代码来源:BlogGuestBookSubmission.php

示例6: LatestTweetsList

 public function LatestTweetsList($limit = '5')
 {
     $conf = SiteConfig::current_site_config();
     if (empty($conf->TwitterName) || empty($conf->TwitterConsumerKey) || empty($conf->TwitterConsumerSecret) || empty($conf->TwitterAccessToken) || empty($conf->TwitterAccessTokenSecret)) {
         return new ArrayList();
     }
     $cache = SS_Cache::factory('LatestTweets_cache');
     if (!($results = unserialize($cache->load(__FUNCTION__)))) {
         $results = new ArrayList();
         require_once dirname(__FILE__) . '/tmhOAuth/tmhOAuth.php';
         require_once dirname(__FILE__) . '/tmhOAuth/tmhUtilities.php';
         $tmhOAuth = new tmhOAuth(array('consumer_key' => $conf->TwitterConsumerKey, 'consumer_secret' => $conf->TwitterConsumerSecret, 'user_token' => $conf->TwitterAccessToken, 'user_secret' => $conf->TwitterAccessTokenSecret, 'curl_ssl_verifypeer' => false));
         $code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline'), array('screen_name' => $conf->TwitterName, 'count' => $limit));
         $tweets = $tmhOAuth->response['response'];
         $json = new JSONDataFormatter();
         if (($arr = $json->convertStringToArray($tweets)) && is_array($arr) && isset($arr[0]['text'])) {
             foreach ($arr as $tweet) {
                 try {
                     $here = new DateTime(SS_Datetime::now()->getValue());
                     $there = new DateTime($tweet['created_at']);
                     $there->setTimezone($here->getTimezone());
                     $date = $there->Format('Y-m-d H:i:s');
                 } catch (Exception $e) {
                     $date = 0;
                 }
                 $results->push(new ArrayData(array('Text' => nl2br(tmhUtilities::entify_with_options($tweet, array('target' => '_blank'))), 'Date' => SS_Datetime::create_field('SS_Datetime', $date))));
             }
         }
         $cache->save(serialize($results), __FUNCTION__);
     }
     return $results;
 }
开发者ID:unisolutions,项目名称:silverstripe-latesttweets,代码行数:32,代码来源:LaTw_Page_Controller_Extension.php

示例7: SaveDeployment

 function SaveDeployment($data, $form)
 {
     $id = convert::raw2sql($data['DeploymentID']);
     // Only loaded if it belongs to current user
     $Deployment = $form->controller->LoadDeployment($id);
     // If a deployment wasn't returned, we'll create a new one
     if (!$Deployment) {
         $Deployment = new Deployment();
         $Deployment->OrgID = Member::currentUser()->getCurrentOrganization()->ID;
         $newDeploy = true;
     }
     $form->saveInto($Deployment);
     $survey = $form->controller->GetCurrentSurvey();
     $Deployment->DeploymentSurveyID = $survey->ID;
     $Deployment->UpdateDate = SS_Datetime::now()->Rfc2822();
     $Deployment->OrgID = $survey->OrgID;
     $Deployment->write();
     /**/
     $survey->CurrentStep = 'MoreDeploymentDetails';
     $survey->HighestStepAllowed = 'MoreDeploymentDetails';
     $survey->UpdateDate = SS_Datetime::now()->Rfc2822();
     $survey->write();
     // If it is a new deployment and it is public, we send an email...
     if (isset($newDeploy) && $Deployment->IsPublic === 1) {
         global $email_new_deployment;
         global $email_from;
         $email = EmailFactory::getInstance()->buildEmail($email_from, $email_new_deployment, 'New Deployment');
         $email->setTemplate('NewDeploymentEmail');
         $email->populateTemplate(array('Deployment' => $Deployment));
         $email->send();
     }
     Session::set('CurrentDeploymentID', $Deployment->ID);
     Controller::curr()->redirect($form->controller->Link() . 'MoreDeploymentDetails');
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:34,代码来源:DeploymentSurveyDeploymentDetailsForm.php

示例8: populateDefaults

 /**
  * Add the default for the Date being the current day.
  */
 public function populateDefaults()
 {
     parent::populateDefaults();
     if (!isset($this->Date) || $this->Date === null) {
         $this->Date = SS_Datetime::now()->Format('Y-m-d H:i:s');
     }
 }
开发者ID:helpfulrobot,项目名称:gdmedia-silverstripe-gdm-express,代码行数:10,代码来源:NewsPage.php

示例9: prepareAndGenerate

 /**
  * Prepares this combined report
  *
  * Functions the same as the parent class, but we need to
  * clone the Related reports too
  *
  * @return CombinedReport
  */
 public function prepareAndGenerate()
 {
     $report = $this->duplicate(false);
     $report->ReportID = $this->ID;
     $report->Created = SS_Datetime::now();
     $report->LastEdited = SS_Datetime::now();
     $report->Title = $this->GeneratedReportTitle;
     $report->write();
     $toClone = $this->ChildReports();
     if ($toClone) {
         foreach ($toClone as $child) {
             $clonedChild = $child->duplicate(false);
             $clonedChild->Created = SS_Datetime::now();
             $clonedChild->LastEdited = SS_Datetime::now();
             $clonedChild->CombinedReportID = $report->ID;
             $clonedChild->write();
         }
     }
     $report->generateReport('html');
     $report->generateReport('csv');
     if (class_exists('PdfRenditionService')) {
         $report->generateReport('pdf');
     }
     return $report;
 }
开发者ID:helpfulrobot,项目名称:maldicore-advancedreports,代码行数:33,代码来源:CombinedReport.php

示例10: FilteredBlogEntries

 /**
  * Determine selected BlogEntry items to show on this page
  * 
  * @param int $limit
  * @return PaginatedList
  */
 public function FilteredBlogEntries($limit = null)
 {
     require_once 'Zend/Date.php';
     if ($limit === null) {
         $limit = BlogTree::$default_entries_limit;
     }
     // only use freshness if no action is present (might be displaying tags or rss)
     if ($this->owner->LandingPageFreshness && !$this->owner->request->param('Action')) {
         $d = new Zend_Date(SS_Datetime::now()->getValue());
         $d->sub($this->owner->LandingPageFreshness, Zend_Date::MONTH);
         $date = $d->toString('YYYY-MM-dd');
         $filter = "\"BlogEntry\".\"Date\" > '{$date}'";
     } else {
         $filter = '';
     }
     // allow filtering by author field and some blogs have an authorID field which
     // may allow filtering by id
     if (isset($_GET['author']) && isset($_GET['authorID'])) {
         $author = Convert::raw2sql($_GET['author']);
         $id = Convert::raw2sql($_GET['authorID']);
         $filter .= " \"BlogEntry\".\"Author\" LIKE '" . $author . "' OR \"BlogEntry\".\"AuthorID\" = '" . $id . "'";
     } else {
         if (isset($_GET['author'])) {
             $filter .= " \"BlogEntry\".\"Author\" LIKE '" . Convert::raw2sql($_GET['author']) . "'";
         } else {
             if (isset($_GET['authorID'])) {
                 $filter .= " \"BlogEntry\".\"AuthorID\" = '" . Convert::raw2sql($_GET['authorID']) . "'";
             }
         }
     }
     $date = $this->owner->SelectedDate();
     return $this->owner->Entries($limit, $this->owner->SelectedTag(), $date ? $date : '', array(get_class($this), 'FilterByDate'), $filter);
 }
开发者ID:helpfulrobot,项目名称:zirak-blog-post-publication-period,代码行数:39,代码来源:AdminPublicationPostDate.php

示例11: process

 public function process()
 {
     $nextTask = DevTaskRun::get_next_task();
     if ($nextTask) {
         //create task instance
         $task = Injector::inst()->create($nextTask->Task);
         //get params
         $params = explode(' ', $nextTask->Params);
         $paramList = array();
         if ($params) {
             foreach ($params as $param) {
                 $parts = explode('=', $param);
                 if (count($parts) === 2) {
                     $paramList[$parts[0]] = $parts[1];
                 }
             }
         }
         echo 'Starting task ' . $task->getTitle() . "\n";
         //remove so it doesn't get rerun
         $nextTask->Status = 'Running';
         $nextTask->write();
         $request = new SS_HTTPRequest('GET', 'dev/tasks/' . $nextTask->Task, $paramList);
         $task->run($request);
         $nextTask->Status = 'Finished';
         $nextTask->FinishDate = SS_Datetime::now()->getValue();
         $nextTask->write();
         echo 'Finished task ' . $task->getTitle() . "\n";
     }
 }
开发者ID:helpfulrobot,项目名称:webtorque-dev-task-runner,代码行数:29,代码来源:DevTaskRunnerCronTask.php

示例12: getEventsAction

 public function getEventsAction(SS_HTTPRequest $request)
 {
     // Search date
     $date = DBField::create_field("SS_Datetime", $request->param("SearchDate"));
     if (!$date->getValue()) {
         $date = SS_Datetime::now();
     }
     // Get event data
     $cache = SS_Cache::factory(self::EVENTS_CACHE_NAME);
     $cacheKey = $date->Format('Y_m_d');
     if ($result = $cache->load($cacheKey)) {
         $data = unserialize($result);
     } else {
         $data = EventsDataUtil::get_events_data_for_day($date);
         $cache->save(serialize($data), $cacheKey);
     }
     // Get init data
     if ($request->param("GetAppConfig")) {
         $cache = SS_Cache::factory(self::CONFIG_CACHE_NAME);
         $cacheKey = 'APP_CONFIG';
         if ($result = $cache->load($cacheKey)) {
             $configData = unserialize($result);
         } else {
             $configData = AppConfigDataUtil::get_config_data();
             $cache->save(serialize($configData), $cacheKey);
         }
         $data['appConfig'] = $configData;
     }
     return $this->sendResponse($data);
 }
开发者ID:ehyland,项目名称:some-painter-cms,代码行数:30,代码来源:EventsController.php

示例13: augmentSQL

 /**
  * Augment queries so that we don't fetch unpublished articles.
  **/
 public function augmentSQL(SQLQuery &$query)
 {
     $stage = Versioned::current_stage();
     if ($stage == 'Live' || !Permission::check("VIEW_DRAFT_CONTENT")) {
         $query->addWhere("PublishDate < '" . Convert::raw2sql(SS_Datetime::now()) . "'");
     }
 }
开发者ID:helpfulrobot,项目名称:micmania1-silverstripe-blog,代码行数:10,代码来源:BlogPostFilter.php

示例14: generatePrintData

 /**
  * Export core
  *
  * Replaces definition in GridFieldPrintButton
  * same as original except sources data from $gridField->getList() instead of $gridField->getManipulatedList()
  *
  * @param GridField
  */
 public function generatePrintData(GridField $gridField)
 {
     $printColumns = $this->getPrintColumnsForGridField($gridField);
     $header = null;
     if ($this->printHasHeader) {
         $header = new ArrayList();
         foreach ($printColumns as $field => $label) {
             $header->push(new ArrayData(array("CellString" => $label)));
         }
     }
     // The is the only variation from the parent class, using getList() instead of getManipulatedList()
     $items = $gridField->getList();
     $itemRows = new ArrayList();
     foreach ($items as $item) {
         $itemRow = new ArrayList();
         foreach ($printColumns as $field => $label) {
             $value = $gridField->getDataFieldValue($item, $field);
             $itemRow->push(new ArrayData(array("CellString" => $value)));
         }
         $itemRows->push(new ArrayData(array("ItemRow" => $itemRow)));
         $item->destroy();
     }
     $ret = new ArrayData(array("Title" => $this->getTitle($gridField), "Header" => $header, "ItemRows" => $itemRows, "Datetime" => SS_Datetime::now(), "Member" => Member::currentUser()));
     return $ret;
 }
开发者ID:mandrew,项目名称:silverstripe-securityreport,代码行数:33,代码来源:GridFieldPrintReportButton.php

示例15: getCurrentSprint

 function getCurrentSprint()
 {
     $now = SS_Datetime::now()->URLDate();
     $currentSprints = $this->Sprints("StartDate <= '{$now}' && EndDate >= '{$now}'");
     if ($currentSprints) {
         return $currentSprints->first();
     }
 }
开发者ID:robert-h-curry,项目名称:retronaut,代码行数:8,代码来源:ScrumTeam.php


注:本文中的SS_Datetime::now方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。