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


PHP Date::setValue方法代码示例

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


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

示例1: FeedItems

	function FeedItems() {
		$output = new DataObjectSet();
		
		include_once(Director::getAbsFile(SAPPHIRE_DIR . '/thirdparty/simplepie/SimplePie.php'));
		
		$t1 = microtime(true);
		$this->feed = new SimplePie($this->AbsoluteRssUrl, TEMP_FOLDER);
		$this->feed->init();
		if($items = $this->feed->get_items(0, $this->NumberToShow)) {
			foreach($items as $item) {
				
				// Cast the Date
				$date = new Date('Date');
				$date->setValue($item->get_date());

				// Cast the Title
				$title = new Text('Title');
				$title->setValue($item->get_title());

				$output->push(new ArrayData(array(
					'Title' => $title,
					'Date' => $date,
					'Link' => $item->get_link()
				)));
			}
			return $output;
		}
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:28,代码来源:RSSWidget.php

示例2: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $createdDate = new Date();
     $createdDate->setValue($this->Created);
     $reviewer = $this->Member()->Name;
     $email = $this->Member()->Email;
     $star = "★";
     $emptyStar = "☆";
     $fields->insertBefore(LiteralField::create('reviewer', '<p>Written by <strong>' . $this->getMemberDetails() . '</strong><br />' . $createdDate->Format('l F jS Y h:i:s A') . '</p>'), 'Title');
     $fields->insertBefore(CheckboxField::create('Approved'), 'Title');
     $starRatings = $this->StarRatings();
     foreach ($starRatings as $starRating) {
         $cat = $starRating->StarRatingCategory;
         $stars = str_repeat($star, $starRating->Rating);
         $ratingStars = $stars;
         $maxRating = $starRating->MaxRating - $starRating->Rating;
         $emptyStarRepeat = str_repeat($emptyStar, $maxRating);
         $emptyStars = $emptyStarRepeat;
         /* 4/5 Stars */
         $ratingInfo = $ratingStars . $emptyStars . ' (' . $starRating->Rating . ' of ' . $starRating->MaxRating . ' Stars)';
         $fields->insertBefore(ReadonlyField::create('rating_' . $cat, $cat, html_entity_decode($ratingInfo, ENT_COMPAT, 'UTF-8')), 'Title');
     }
     $fields->removeByName('StarRatings');
     $fields->removeByName('MemberID');
     $fields->removeByName('ProductID');
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:clintlandrum-silverstripe-productreviews,代码行数:28,代码来源:ProductReview.php

示例3: getArchive

 /**
  * Returns a list of months where blog posts are present.
  *
  * @return DataList
  */
 public function getArchive()
 {
     $query = $this->Blog()->getBlogPosts()->dataQuery();
     if ($this->ArchiveType == 'Yearly') {
         $query->groupBy('DATE_FORMAT("PublishDate", \'%Y\')');
     } else {
         $query->groupBy('DATE_FORMAT("PublishDate", \'%Y-%M\')');
     }
     $posts = $this->Blog()->getBlogPosts()->setDataQuery($query);
     if ($this->NumberToDisplay > 0) {
         $posts = $posts->limit($this->NumberToDisplay);
     }
     $archive = new ArrayList();
     if ($posts->count() > 0) {
         foreach ($posts as $post) {
             /**
              * @var BlogPost $post
              */
             $date = new Date();
             $date->setValue($post->PublishDate);
             if ($this->ArchiveType == 'Yearly') {
                 $year = $date->FormatI18N("%Y");
                 $month = null;
                 $title = $year;
             } else {
                 $year = $date->FormatI18N("%Y");
                 $month = $date->FormatI18N("%m");
                 $title = $date->FormatI18N("%B %Y");
             }
             $archive->push(new ArrayData(array('Title' => $title, 'Link' => Controller::join_links($this->Blog()->Link('archive'), $year, $month))));
         }
     }
     return $archive;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-blog,代码行数:39,代码来源:BlogArchiveWidget.php

示例4: RSSItems

 /**
  * Gets a list of all the items in the RSS feed given a user-provided URL, limit, and date format
  *
  * @return ArrayList
  */
 public function RSSItems()
 {
     if (!$this->FeedURL) {
         return false;
     }
     $doc = new DOMDocument();
     @$doc->load($this->FeedURL);
     $items = $doc->getElementsByTagName('item');
     $feeds = array();
     foreach ($items as $node) {
         $itemRSS = array('title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue);
         $feeds[] = $itemRSS;
     }
     $output = ArrayList::create(array());
     $count = 0;
     foreach ($feeds as $item) {
         if ($count >= $this->Count) {
             break;
         }
         // Cast the Date
         $date = new Date('Date');
         $date->setValue($item['date']);
         // Cast the Title
         $title = new Text('Title');
         $title->setValue($item['title']);
         $output->push(new ArrayData(array('Title' => $title, 'Date' => $date->Format($this->DateFormat), 'Link' => $item['link'])));
         $count++;
     }
     return $output;
 }
开发者ID:helpfulrobot,项目名称:unclecheese-dashboard,代码行数:35,代码来源:DashboardRSSFeedPanel.php

示例5: testLongDate

 function testLongDate()
 {
     /* "24 May 2006" style formatting of Date::Long() */
     $cases = array('2003-4-3' => '3 April 2003', '3/4/2003' => '3 April 2003');
     foreach ($cases as $original => $expected) {
         $date = new Date();
         $date->setValue($original);
         $this->assertEquals($expected, $date->Long());
     }
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:10,代码来源:DateTest.php

示例6: getHTMLFragments

 /**
  * @param GridField $grid
  * @return array
  */
 public function getHTMLFragments($grid)
 {
     $cols = new ArrayList();
     foreach ($grid->getColumns() as $name) {
         $meta = $grid->getColumnMetadata($name);
         $cols->push(new ArrayData(array('Name' => $name, 'Title' => $meta['title'])));
     }
     $days = new ArrayList();
     for ($i = 0; $i < 5; $i++) {
         $date = new Date();
         $date->setValue(date('d-m-Y', strtotime('+' . $i . ' days', strtotime($this->startDate))));
         $isHoliday = in_array($date->Format('Y-m-d'), $this->holidays);
         $days->push(new ArrayData(array('Day' => $date->Format('l'), 'IsHoliday' => $isHoliday)));
     }
     return array('header' => $cols->renderWith('RosterGridFieldTitleHeader', array('StartDate' => $this->startDate, 'Days' => $days)));
 }
开发者ID:helpfulrobot,项目名称:danae-miller-clendon-silverstripe-roster,代码行数:20,代码来源:RosterGridFieldTitleHeader.php

示例7: getNotifications

 private function getNotifications($request)
 {
     $currentUserID = Member::currentUser()->ID;
     $notifications = MemberNotification::get()->innerJoin('MemberNotification_NotificationMembers', '"MemberNotification"."ID"="MemberNotification_NotificationMembers"."MemberNotificationID"')->where("\"MemberNotification_NotificationMembers\".\"MemberID\" = {$currentUserID}")->sort('LastEdited', 'DESC');
     $notificationArray = array();
     if ($notifications) {
         foreach ($notifications as $notification) {
             $notificationReadStatus = DB::query("Select ReadStatus FROM \"MemberNotification_NotificationMembers\"\n\t\t\t\t\tWHERE \"MemberNotificationID\" = {$notification->ID} AND \"MemberID\" = {$currentUserID} LIMIT 1")->value();
             $date = new Date();
             $date->setValue($notification->LastEdited);
             $user = Member::get()->byID($notification->CreatedByMemberID);
             $notificationArray[] = array("id" => $notification->ID, "title" => $notification->MemberNotificationTitle, "message" => $notification->MemberNotificationMessage, "date" => $date->Format('j M Y'), "user" => $user ? $user->FirstName . ' ' . $user->SurName : '', "read" => $notificationReadStatus);
         }
     }
     return $this->jsonPacket($notificationArray);
 }
开发者ID:helpfulrobot,项目名称:nadzweb-membernotification,代码行数:16,代码来源:MemberNotificationController.php

示例8: apply

 /**
  *
  *@return SQLQuery
  **/
 public function apply(DataQuery $query)
 {
     $value = $this->getValue();
     $date = new Date();
     $date->setValue($value);
     $distanceFromToday = time() - strtotime($value);
     $maxDays = round($distanceFromToday / ($this->divider * 2 * 86400)) + 1;
     $formattedDate = $date->format("Y-m-d");
     $db = DB::getConn();
     if ($db instanceof PostgreSQLDatabase) {
         // don't know whether functions should be used, hence the following code using an interval cast to an integer
         $query->where("(\"Order\".\"LastEdited\"::date - '{$formattedDate}'::date)::integer > -" . $maxDays . " AND (\"Order\".\"Created\"::date - '{$formattedDate}'::date)::integer < " . $maxDays);
     } else {
         // default is MySQL DATEDIFF() function - broken for others, each database conn type supported must be checked for!
         $query->where("(DATEDIFF(\"Order\".\"LastEdited\", '{$formattedDate}') > -" . $maxDays . " AND DATEDIFF(\"Order\".\"Created\", '{$formattedDate}') < " . $maxDays . ")");
     }
     return $query;
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:22,代码来源:OrderFilters.php

示例9: apply

 public function apply(SQLQuery $query)
 {
     $query = $this->applyRelation($query);
     $value = $this->getValue();
     $date = new Date();
     $date->setValue($value);
     $formattedDate = $date->format("Y-m-d");
     // changed for PostgreSQL compatability
     // NOTE - we may wish to add DATEDIFF function to PostgreSQL schema, it's just that this would be the FIRST function added for SilverStripe
     $db = DB::getConn();
     if ($db instanceof PostgreSQLDatabase) {
         // don't know whether functions should be used, hence the following code using an interval cast to an integer
         return $query->where("(\"Order\".\"Created\"::date - '{$formattedDate}'::date)::integer > -" . self::get_how_many_days_around() . " AND (\"Order\".\"Created\"::date - '{$formattedDate}'::date)::integer < " . self::get_how_many_days_around());
     } else {
         // default is MySQL DATEDIFF() function - broken for others, each database conn type supported must be checked for!
         return $query->where("(DATEDIFF(\"Order\".\"Created\", '{$formattedDate}') > -" . self::get_how_many_days_around() . " AND DATEDIFF(\"Order\".\"Created\", '{$formattedDate}') < " . self::get_how_many_days_around() . ")");
     }
 }
开发者ID:riddler7,项目名称:silverstripe-ecommerce,代码行数:18,代码来源:OrderFilters.php

示例10: Dates

	function Dates() {
		Requirements::themedCSS('archivewidget');
		
		$results = new DataObjectSet();
		$blogHolder = $this->getBlogHolder();
		$id = $blogHolder->ID;
		
		$stage = Versioned::current_stage();
		$suffix = (!$stage || $stage == 'Stage') ? "" : "_$stage";

		
		if($this->DisplayMode == 'month') {
			$sqlResults = DB::query("SELECT DISTINCT MONTH(`Date`) AS `Month`, YEAR(`Date`) AS `Year` FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix` WHERE `ParentID` = $id ORDER BY `Date` DESC");	
		} else {
			$sqlResults = DB::query("SELECT DISTINCT YEAR(`Date`) AS `Year` FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix` WHERE `ParentID` = $id ORDER BY `Date` DESC");
		}
		
		if(!$sqlResults) return new DataObjectSet();
		
		foreach($sqlResults as $sqlResult) {
			$date = new Date('Date');
			$month = ($this->DisplayMode == 'month') ? (int)$sqlResult['Month'] : 1;
			
			$date->setValue(array(
				'Day' => 1,
				'Month' => $month, 
				'Year' => (int) $sqlResult['Year']
			));
			
			if($this->DisplayMode == 'month') {
				$link = $blogHolder->Link() . $sqlResult['Year']. '/' . sprintf("%'02d", $sqlResult['Month']);
			} else {
				$link = $blogHolder->Link() . $sqlResult['Year'];
			}
			
			$results->push(new ArrayData(array(
				'Date' => $date,
				'Link' => $link
			)));
		}
		
		return $results;
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:43,代码来源:ArchiveWidget.php

示例11: applyOne

 /**
  *
  *@return SQLQuery
  **/
 public function applyOne(DataQuery $query)
 {
     //$this->model = $query->applyRelation($this->relation);
     $value = $this->getValue();
     $date = new Date();
     $date->setValue($value);
     $distanceFromToday = time() - strtotime($value);
     $maxDays = round($distanceFromToday / ($this->divider * 2 * 86400)) + 1;
     $formattedDate = $date->format("Y-m-d");
     // changed for PostgreSQL compatability
     // NOTE - we may wish to add DATEDIFF function to PostgreSQL schema, it's just that this would be the FIRST function added for SilverStripe
     // default is MySQL DATEDIFF() function - broken for others, each database conn type supported must be checked for!
     $db = DB::getConn();
     if ($db instanceof PostgreSQLDatabase) {
         // don't know whether functions should be used, hence the following code using an interval cast to an integer
         $query->where("(\"EcommercePayment\".\"Created\"::date - '{$formattedDate}'::date)::integer > -" . $maxDays . " AND (\"EcommercePayment\".\"Created\"::date - '{$formattedDate}'::date)::integer < " . $maxDays);
     } else {
         // default is MySQL DATEDIFF() function - broken for others, each database conn type supported must be checked for!
         $query->where("(DATEDIFF(\"EcommercePayment\".\"Created\", '{$formattedDate}') > -" . $maxDays . " AND DATEDIFF(\"EcommercePayment\".\"Created\", '{$formattedDate}') < " . $maxDays . ")");
     }
     return $query;
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:26,代码来源:EcommercePaymentFilters.php

示例12: FeedItems

 function FeedItems()
 {
     $output = new DataObjectSet();
     // Protection against infinite loops when an RSS widget pointing to this page is added to this page
     if (stristr($_SERVER['HTTP_USER_AGENT'], 'SimplePie')) {
         return $output;
     }
     include_once Director::getAbsFile(SAPPHIRE_DIR . '/thirdparty/simplepie/simplepie.inc');
     $t1 = microtime(true);
     $feed = new SimplePie($this->AbsoluteRssUrl, TEMP_FOLDER);
     $feed->init();
     if ($items = $feed->get_items(0, $this->NumberToShow)) {
         foreach ($items as $item) {
             // Cast the Date
             $date = new Date('Date');
             $date->setValue($item->get_date());
             // Cast the Title
             $title = new Text('Title');
             $title->setValue($item->get_title());
             $output->push(new ArrayData(array('Title' => $title, 'Date' => $date, 'Link' => $item->get_link())));
         }
         return $output;
     }
 }
开发者ID:nicmart,项目名称:comperio-site,代码行数:24,代码来源:RSSWidget.php

示例13: Now

	/**
	 * returns a date object for use within a template
	 * Usage: $Now.Year - Returns 2006
	 * @return Date The current date
	 */
	function Now() {
		$d = new Date(null);
		$d->setValue(date("Y-m-d h:i:s"));
		return $d;
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:10,代码来源:Controller.php

示例14: Field

 function Field()
 {
     if ($this->value) {
         $df = new Date($this->name);
         $df->setValue($this->dataValue());
         $val = Convert::raw2xml($this->value);
     } else {
         $val = '<i>' . _t('Form.NOTSET', '(not set)') . '</i>';
     }
     return "<span class=\"readonly\" id=\"" . $this->id() . "\">{$val}</span>";
 }
开发者ID:helpfulrobot,项目名称:silverstripe-legacydatetimefields,代码行数:11,代码来源:CompositeDateField.php

示例15: Field

 function Field($properties = array())
 {
     if ($this->valueObj) {
         if ($this->valueObj->isToday()) {
             $val = Convert::raw2xml($this->valueObj->toString($this->getConfig('dateformat')) . ' (' . _t('DateField.TODAY', 'today') . ')');
         } else {
             $df = new Date($this->name);
             $df->setValue($this->dataValue());
             $val = Convert::raw2xml($this->valueObj->toString($this->getConfig('dateformat')) . ', ' . $df->Ago());
         }
     } else {
         $val = '<i>(' . _t('DateField.NOTSET', 'not set') . ')</i>';
     }
     return "<span class=\"readonly\" id=\"" . $this->id() . "\">{$val}</span>";
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:15,代码来源:DateField.php


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