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


PHP object::format方法代码示例

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


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

示例1: commit

 /**
  * Commit changes to this date
  */
 public function commit()
 {
     $this->validate();
     $data = array("date" => $this->Date->format("Y-m-d"), "text" => $this->text, "meta" => json_encode($this->meta), "location_id" => $this->Location->id, "type_id" => $this->Type->id);
     if (filter_var($this->id, FILTER_VALIDATE_INT)) {
         // Update
         $where = array("id = ?" => $this->id);
         $this->db->update("location_date", $data, $where);
     } else {
         // Insert
         $this->db->insert("location_date", $data);
         $this->id = $this->db->lastInsertId();
     }
     return true;
 }
开发者ID:railpage,项目名称:railpagecore,代码行数:18,代码来源:Date.php

示例2: commit

 /**
  * Commit changes to a sighting
  * @since Version 3.5
  */
 public function commit()
 {
     $this->validate();
     $data = array("date" => $this->date->format("Y-m-d H:i:s"), "date_added" => $this->date_added->format("Y-m-d H:i:s"), "lat" => $this->lat, "lon" => $this->lon, "text" => $this->text, "traincode" => $this->train_number, "user_id" => $this->user_id, "timezone" => $this->timezone, "loco_ids" => implode(",", array_map('intval', $this->loco_ids)));
     if (filter_var($this->id, FILTER_VALIDATE_INT)) {
         $where = array("id = ?" => $this->id);
         $this->db->update("sighting", $data, $where);
     } else {
         $this->db->insert("sighting", $data);
         $this->id = $this->db->lastInsertId();
     }
     /*
     if (filter_var($this->id, FILTER_VALIDATE_INT)) {
         $where = array(
             "sighting_id = ?" => $this->id
         );
         
         $this->db->delete("sighting_locos", $where); 
         
         foreach ($this->loco_ids as $loco_id) {
             $data = array(
                 "sighting_id" => $this->id,
                 "loco_id" => $loco_id
             );
             
             $this->db->insert("sighting_locos", $data); 
         }
     }
     */
     return true;
 }
开发者ID:railpage,项目名称:railpagecore,代码行数:35,代码来源:Sighting.php

示例3: lastDayMonth

 /**
  * Return last day of current month
  *
  * @since  Oct, 18 2016
  * @return integer
  */
 public function lastDayMonth()
 {
     $days = 0;
     switch ($this->calendar_type) {
         case 'gregorian':
             $days = intval($this->date_time->format('m')) == 2 && $this->config['leap_year']($this->date_time->format('Y')) ? $this->config['month_days_number'][intval($this->date_time->format('m'))] + 1 : $this->config['month_days_number'][intval($this->date_time->format('m'))];
             break;
         case 'jalali':
             $days = intval($this->date_time->format('m')) == 12 && $this->config['leap_year']($this->date_time->format('Y')) ? $this->config['month_days_number'][intval($this->date_time->format('m'))] + 1 : $this->config['month_days_number'][intval($this->date_time->format('m'))];
             break;
         default:
             $days = $this->config['month_days_number'][intval($this->date_time->format('m'))];
             break;
     }
     return $days;
 }
开发者ID:opencafe,项目名称:datium,代码行数:22,代码来源:DayOf.php

示例4: normalize

 /**
  * @param object $object
  * @param string $format
  * @param array  $context
  *
  * @return string
  */
 public function normalize($object, $format = null, array $context = array())
 {
     if (!$object instanceof \DateTimeInterface) {
         throw new InvalidArgumentException('The object must implement the "\\DateTimeInterface".');
     }
     $format = isset($context[static::CONTEXT_FORMAT]) ? $context[self::CONTEXT_FORMAT] : $this->format;
     return $object->format($format);
 }
开发者ID:mihai-stancu,项目名称:serializer,代码行数:15,代码来源:DateTimeNormalizer.php

示例5: dateFormat

 /**
  * Return a formatted date string.
  *
  * @param int|object|string $date
  * @param string            $format
  *
  * @return string
  */
 public function dateFormat($date, string $format = 'M d Y') : string
 {
     if ($date instanceof DateTime) {
         return $date->format($format);
     } elseif (is_int($date)) {
         return date($format, $date);
     }
     return date($format, strtotime($date));
 }
开发者ID:atorscho,项目名称:laravel-helpers,代码行数:17,代码来源:Miscellaneous.php

示例6: _convert_from_string_value_to_utc_unix_timestamp

 /**
  * @param $datetime
  * @return string
  * @throws EE_Error
  */
 private function _convert_from_string_value_to_utc_unix_timestamp($datetime)
 {
     //create a new datetime object using the given string and timezone
     $this->_set_date_obj($datetime, $this->_timezone);
     if (!$this->_date instanceof DateTime && !$this->_nullable) {
         throw new EE_Error(__('Something went wrong with setting the date/time. Likely, either there is an invalid datetime string or an invalid timezone string being used.', 'event_espresso'));
     }
     $this->_date->setTimezone(EE_Datetime_Field::get_UTC_DateTimeZone());
     return $this->_date->format('U');
 }
开发者ID:robert-osborne,项目名称:event-espresso-core-1,代码行数:15,代码来源:EE_Datetime_Field.php

示例7: toArray

 /**
  * @param object $object
  * @return array
  */
 private function toArray($object)
 {
     if ($object instanceof DateTimeInterface) {
         return ['time' => $object->format('Y-m-d\\TH:i:s.uO')];
     }
     if ($object instanceof UuidInterface) {
         return ['uuid' => (string) $object];
     }
     return $this->extractValuesFromObject($object);
 }
开发者ID:pauci,项目名称:cqrs,代码行数:14,代码来源:ReflectionSerializer.php

示例8: commit

 /**
  * Save changes
  * @since Version 3.10.0
  * @return \Railpage\Content\Page
  */
 public function commit()
 {
     $this->validate();
     $data = ["title" => $this->title, "subtitle" => $this->subtitle, "active" => $this->active, "page_header" => $this->header, "text" => $this->body, "page_footer" => $this->footer, "date" => $this->date->format("Y-m-d H:i:s"), "counter" => $this->hits, "clanguage" => $this->language, "shortname" => $this->permalink];
     if (filter_var($this->id, FILTER_VALIDATE_INT)) {
         $where = ["pid = ?" => $this->id];
         $this->db->update("nuke_pages", $data, $where);
         return $this;
     }
     $this->db->insert("nuke_pages", $data);
     $this->id = $this->db->lastInsertId();
     return $this;
 }
开发者ID:railpage,项目名称:railpagecore,代码行数:18,代码来源:Page.php

示例9: commit

 /**
  * Commit changes to this link
  * @since Version 3.7.5
  * @return boolean
  */
 public function commit()
 {
     $this->validate();
     $data = array("cid" => $this->Category->id, "title" => $this->name, "url" => $this->url, "description" => $this->desc, "date" => $this->Date->format("Y-m-d H:i:s"), "user_id" => $this->user_id, "link_broken" => intval($this->broken), "link_approved" => intval($this->approved));
     if (filter_var($this->id, FILTER_VALIDATE_INT)) {
         $where = array("lid = ?" => $this->id);
         $rs = $this->db->update("nuke_links_links", $data, $where);
     } else {
         $rs = $this->db->insert("nuke_links_links", $data);
         $this->id = $this->db->lastInsertId();
     }
     return $rs;
 }
开发者ID:railpage,项目名称:railpagecore,代码行数:18,代码来源:Link.php

示例10: readObject

 /**
  * Reads a string representation from an object
  *
  * @param object $object The object
  *
  * @return string
  */
 protected static function readObject($object) : string
 {
     if ($object instanceof Closure) {
         return 'Function';
     }
     if ($object instanceof DateTime) {
         return sprintf('DateTime(%s)', $object->format('Y-m-d\\TH:i:sP'));
     }
     if (method_exists($object, 'toString')) {
         return (string) $object->toString();
     }
     if (method_exists($object, '__toString')) {
         return (string) $object;
     }
     return sprintf('Object(%s)', get_class($object));
 }
开发者ID:novuso,项目名称:system,代码行数:23,代码来源:VarPrinter.php

示例11: datetimeRangeYears

 /**
  * Specifies the start and end year to use as a date range.
  *
  * Handles a string like -3:+3 or 2001:2010 to describe a dynamic range of
  * minimum and maximum years to use in a date selector.
  *
  * Centers the range around the current year, if any, but expands it far enough
  * so it will pick up the year value in the field in case the value in the field
  * is outside the initial range.
  *
  * @param string $string
  *   A min and max year string like '-3:+1' or '2000:2010' or '2000:+3'.
  * @param object $date
  *   (optional) A date object to test as a default value. Defaults to NULL.
  *
  * @return array
  *   A numerically indexed array, containing the minimum and maximum year
  *   described by this pattern.
  */
 protected static function datetimeRangeYears($string, $date = NULL)
 {
     $datetime = new DrupalDateTime();
     $this_year = $datetime->format('Y');
     list($min_year, $max_year) = explode(':', $string);
     // Valid patterns would be -5:+5, 0:+1, 2008:2010.
     $plus_pattern = '@[\\+|\\-][0-9]{1,4}@';
     $year_pattern = '@^[0-9]{4}@';
     if (!preg_match($year_pattern, $min_year, $matches)) {
         if (preg_match($plus_pattern, $min_year, $matches)) {
             $min_year = $this_year + $matches[0];
         } else {
             $min_year = $this_year;
         }
     }
     if (!preg_match($year_pattern, $max_year, $matches)) {
         if (preg_match($plus_pattern, $max_year, $matches)) {
             $max_year = $this_year + $matches[0];
         } else {
             $max_year = $this_year;
         }
     }
     // We expect the $min year to be less than the $max year. Some custom values
     // for -99:+99 might not obey that.
     if ($min_year > $max_year) {
         $temp = $max_year;
         $max_year = $min_year;
         $min_year = $temp;
     }
     // If there is a current value, stretch the range to include it.
     $value_year = $date instanceof DrupalDateTime ? $date->format('Y') : '';
     if (!empty($value_year)) {
         $min_year = min($value_year, $min_year);
         $max_year = max($value_year, $max_year);
     }
     return array($min_year, $max_year);
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:56,代码来源:DateElementBase.php

示例12: daysToWeekStart

 /**
  * Returns number of days to start of this week.
  *
  * @brief      Days number
  *
  * @author     =stid= <s.furiosi@wpxtre.me>
  *
  * @param object $date Date object
  * @param string $first_day
  *
  * @return int $date
  */
 public static function daysToWeekStart($date, $first_day = 'monday')
 {
     $week_days = array('monday' => 0, 'tuesday' => 1, 'wednesday' => 2, 'thursday' => 3, 'friday' => 4, 'saturday' => 5, 'sunday' => 6);
     $start_day_number = $week_days[$first_day];
     $wday = $date->format("w");
     $current_day_number = $wday != 0 ? $wday - 1 : 6;
     return WPDKMath::rModulus($current_day_number - $start_day_number, 7);
 }
开发者ID:wpxtreme,项目名称:wpdk,代码行数:20,代码来源:wpdk-datetime.php

示例13: makeJSON

 /**
  * Generate JSON object for this article
  * @since Version 3.8.7
  * @return string
  */
 public function makeJSON()
 {
     if ($this->date instanceof DateTime) {
         $timezone = $this->date->getTimezone();
     } else {
         $timezone = new DateTimeZone("Australia/Melbourne");
     }
     if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
         throw new Exception("Cannot make a JSON object for the requested news article beacuse no valid article ID was found. Something's wrong....");
     }
     $response = array("namespace" => $this->Module->namespace, "module" => $this->Module->name, "article" => array("id" => $this->id, "title" => $this->title, "hits" => $this->hits, "blub" => is_object($this->blurb) ? $this->blurb->__toString() : $this->blurb, "body" => is_object($this->body) ? $this->body->__toString() : $this->body, "image" => $this->featured_image, "approved" => $this->approved, "url" => $this->url instanceof Url ? $this->url->getURLs() : array("url" => sprintf("/news/article-%d", $this->id)), "topic" => array("id" => $this->Topic->id, "title" => $this->Topic->title, "url" => $this->Topic->url instanceof Url ? $this->Topic->url->getURLs() : array("url" => sprintf("/news/topic-%d", $this->Topic->id))), "thread" => array("id" => $this->topic_id, "url" => array("view" => filter_var($this->topic_id, FILTER_VALIDATE_INT) ? sprintf("/f-t%d.htm", $this->topic_id) : "")), "date" => array("absolute" => $this->date->format("Y-m-d H:i:s"), "timezone" => $timezone->getName(), "unixtime" => $this->date->getTimestamp()), "author" => array("id" => $this->Author->id, "username" => $this->Author->username, "url" => array("view" => $this->Author->url instanceof Url ? $this->Author->url->url : $this->Author->url)), "staff" => array("id" => $this->Staff->id, "username" => $this->Staff->username, "url" => array("view" => $this->Staff->url instanceof Url ? $this->Staff->url->url : $this->Staff->url))));
     $response = json_encode($response);
     setMemcacheObject(sprintf("json:railpage.news.article=%d", $this->id), $response);
     return $response;
 }
开发者ID:doctorjbeam,项目名称:railpagecore,代码行数:20,代码来源:Article.php

示例14: processObject

 /**
  * Converts the given $object to a string representation considering the $element FormElement definition
  *
  * @param FormElementInterface $element
  * @param object $object
  * @return string
  */
 protected function processObject(FormElementInterface $element, $object)
 {
     $properties = $element->getProperties();
     if ($object instanceof \DateTime) {
         if (isset($properties['dateFormat'])) {
             $dateFormat = $properties['dateFormat'];
             if (isset($properties['displayTimeSelector']) && $properties['displayTimeSelector'] === true) {
                 $dateFormat .= ' H:i';
             }
         } else {
             $dateFormat = \DateTime::W3C;
         }
         return $object->format($dateFormat);
     }
     if ($object instanceof Image) {
         return sprintf('%s Image (%d x %d)', $object->getFileExtension(), $object->getWidth(), $object->getHeight());
     }
     if (method_exists($object, '__toString')) {
         return (string) $object;
     }
     return 'Object [' . get_class($object) . ']';
 }
开发者ID:kitsunet,项目名称:form,代码行数:29,代码来源:RenderValuesViewHelper.php

示例15: _inScope

 /**
  * check if dates are in scope
  *
  * @author Kjell-Inge Gustafsson, kigkonsult <ical@kigkonsult.se>
  * @since 2.21.7 - 2015-03-25
  * @param object $start       datetime
  * @param object $scopeStart  datetime
  * @param object $end         datetime
  * @param object $scopeEnd    datetime
  * @param string $format
  * @return bool
  */
 public static function _inScope($start, $scopeStart, $end, $scopeEnd, $format)
 {
     return $start->format($format) >= $scopeStart->format($format) && $end->format($format) <= $scopeEnd->format($format);
 }
开发者ID:buergimi,项目名称:iCalcreator,代码行数:16,代码来源:iCalUtilityFunctions.class.php


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