本文整理汇总了PHP中Date::Format方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::Format方法的具体用法?PHP Date::Format怎么用?PHP Date::Format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Date
的用法示例。
在下文中一共展示了Date::Format方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例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;
}
示例3: 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
示例4: LabelEnd
/**
* @return string
*/
public function LabelEnd()
{
if (empty($this->_label)) {
$format = Resources::GetInstance()->GetDateFormat('period_time');
return $this->_end->Format($format);
}
return '(' . $this->_label . ')';
}
示例5: 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);
}
示例6: check
public function check()
{
$OdeonCinemaID = (int) $this->request->param("ID");
if ($OdeonCinemaID) {
if ($this->OdeonCinema = OdeonCinema::get_by_id("OdeonCinema", $OdeonCinemaID)) {
$this->OdeonCinema->getCurrentFilms();
$OdeonFilmID = (int) $this->request->param("OtherID");
if ($OdeonFilmID) {
if ($this->OdeonFilm = OdeonFilm::get_by_id("OdeonFilm", $OdeonFilmID)) {
$maxdays = 15;
$baseURL = "https://www.odeon.co.uk/";
$date = new Date();
$RestfulService = new RestfulService($baseURL);
$i = 0;
do {
$date->setValue("+{$i} day");
if (!OdeonScreening::get("OdeonScreening", implode(" AND ", array("DATE_FORMAT(ScreeningTime,'%d%m%y') = '{$date->Format("dmy")}'", "FilmID='{$OdeonFilmID}'", "CinemaID='{$OdeonCinemaID}'")))->Count()) {
$query = array('date' => $date->Format("Y-m-d"), 'siteId' => $OdeonCinemaID, 'filmMasterId' => $OdeonFilmID, 'type' => 'DAY');
$RestfulService->setQueryString($query);
$Response = $RestfulService->request("showtimes/day");
if (!$Response->isError()) {
$html = HtmlDomParser::str_get_html($Response->getBody());
foreach ($html->find('ul') as $ul) {
foreach ($ul->find('li') as $li) {
$ScreeningTime = new SS_Datetime();
$ScreeningTime->setValue("{$date->Format("Y-m-d")} {$li->find('a', 0)->innertext}:00");
$checkAgainstAPI = true;
if ($OdeonScreening = OdeonScreening::get_one("OdeonScreening", implode(" AND ", array("CinemaID='{$OdeonCinemaID}'", "FilmID='{$OdeonFilmID}'", "ScreeningTime='{$ScreeningTime->Rfc2822()}'")))) {
$checkAgainstAPI = $OdeonScreening->checkAgainstAPI();
} else {
$OdeonScreening = new OdeonScreening();
$OdeonScreening->CinemaID = $OdeonCinemaID;
$OdeonScreening->FilmID = $OdeonFilmID;
$OdeonScreening->ScreeningTime = $ScreeningTime->Rfc2822();
}
if ($checkAgainstAPI) {
$URLSegment = str_replace($baseURL, "", $li->find('a', 0)->href);
$Response_init = $RestfulService->request($URLSegment, "GET", null, null, array(CURLOPT_COOKIESESSION => TRUE));
if (!$Response_init->isError()) {
$dom = new DOMDocument();
$dom->strictErrorChecking = FALSE;
libxml_use_internal_errors(true);
$dom->loadHTML($Response_init->getBody());
libxml_clear_errors();
$nodes = $dom->getElementsByTagName('form');
$submit_url = false;
$hidden_inputs = array();
foreach ($nodes as $node) {
if (!$submit_url && $node->hasAttributes()) {
foreach ($node->attributes as $attribute) {
if (!$submit_url && $attribute->nodeName == 'action') {
$submit_url = $attribute->nodeValue;
}
}
}
}
unset($node);
$SubmitURL = ltrim($submit_url, '/');
$Cookies = $Response_init->getHeader("Set-Cookie");
if (is_array($Cookies)) {
$Cookies = implode(';', $Cookies);
}
$Response_availability = $RestfulService->request($SubmitURL, "GET", null, null, array(CURLOPT_COOKIE => $Cookies));
if (!$Response_availability->isError()) {
$html_availability = HtmlDomParser::str_get_html($Response_availability->getBody());
$ticketsTable = $html_availability->find('#tickets-table', 0);
if ($ticketsTable) {
$ticketsForm = $html_availability->find('#tickets', 0);
$data = array("submit" => null);
foreach ($ticketsTable->find('select') as $select) {
$data[$select->attr["name"]] = "0";
}
foreach ($ticketsTable->find('tr') as $tr) {
foreach ($tr->find('td') as $td) {
switch ($td->getAttribute("class")) {
case "ticket-col":
$OdeonScreening->Title = trim($td->innertext);
break;
case "price-col":
$OdeonScreening->Cost = ltrim(explode(" ", trim($td->plaintext))[0], '£');
break;
case "quantity-col":
$Availability = 1;
foreach ($td->find('select') as $select) {
foreach ($select->find('option') as $option) {
$Availability = $option->attr["value"];
}
$data[$select->attr["name"]] = $Availability;
}
$Response_seats = $RestfulService->request(ltrim(html_entity_decode($ticketsForm->attr['action']), "/"), "POST", $data, null, array(CURLOPT_COOKIE => $Cookies));
if (!$Response_seats->isError()) {
$html_seats = HtmlDomParser::str_get_html($Response_seats->getBody());
if (trim($html_seats->find('.step-headline', 0)->innertext) == "Choose your seats") {
$OdeonScreening->Availability = $Availability;
$OdeonScreening->SessionURL = $URLSegment;
$OdeonScreening->duplicate();
}
}
break;
}
//.........这里部分代码省略.........
示例7: OnDateForResource
public function OnDateForResource(Date $date, $resourceId)
{
$key = $date->Format('Ymd') . '|' . $resourceId;
if (!array_key_exists($key, $this->_reservationsByDateAndResource)) {
return array();
}
return $this->_reservationsByDateAndResource[$key];
}
示例8: GetCachedValuesForDate
/**
* @param Date $date
* @return array|SchedulePeriod[]
*/
private function GetCachedValuesForDate($date)
{
$key = $date->Format('Ymd');
if (array_key_exists($date->Format('Ymd'), $this->cachedPeriods)) {
return $this->cachedPeriods[$key];
}
return null;
}
示例9: testDateGetsAdjustedIntoProvidedTimezone
public function testDateGetsAdjustedIntoProvidedTimezone()
{
$format = 'd m y H:i:s';
$tzName = 'US/Eastern';
$baseTz = new DateTimeZone($tzName);
$actual = new Date($this->datestring, $tzName);
$datetime = new DateTime($this->datestring, $baseTz);
$expected = $datetime->format($format);
$this->assertEquals($expected, $actual->Format($format));
}
示例10: getIterationHolidayClass
/**
* Returns either 'holiday' or '' for use in Template
*
* @param int $i Iteration of days
* @return string
*/
private function getIterationHolidayClass($i)
{
$date = new Date();
$thisDateString = date('d-m-Y', strtotime('+' . $i . ' days', strtotime($this->StartDate)));
$date->setValue($thisDateString);
return in_array($date->Format('Y-m-d'), $this->getHolidayArray()) ? 'holiday' : '';
}