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


PHP Carbon::getTimestamp方法代码示例

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


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

示例1: getFilters

 /**
  * Dodatkowe filtry Twig zwiazane z formatowaniem danych uzytkownika
  *
  * @return array
  */
 public function getFilters()
 {
     return [new Twig_SimpleFilter('format_date', function ($dateTime, $diffForHumans = true) {
         $format = Auth::check() ? auth()->user()->date_format : '%Y-%m-%d %H:%M';
         if (!$dateTime instanceof Carbon) {
             $dateTime = new Carbon($dateTime);
         }
         $now = Carbon::now();
         if (!$diffForHumans) {
             return $dateTime->formatLocalized($format);
         } elseif ($dateTime->diffInHours($now) < 1) {
             return $dateTime->diffForHumans(null, true) . ' temu';
         } elseif ($dateTime->isToday()) {
             return 'dziś, ' . $dateTime->format('H:i');
         } elseif ($dateTime->isYesterday()) {
             return 'wczoraj, ' . $dateTime->format('H:i');
         } else {
             return $dateTime->formatLocalized($format);
         }
     }), new Twig_SimpleFilter('timestamp', function ($dateTime) {
         if ($dateTime instanceof Carbon) {
             return $dateTime->getTimestamp();
         } else {
             return strtotime($dateTime);
         }
     })];
 }
开发者ID:furious-programming,项目名称:coyote,代码行数:32,代码来源:User.php

示例2: getTrialEndForUpdate

 /**
  * Get the trial end timestamp for a Stripe subscription update.
  *
  * @return int
  */
 protected function getTrialEndForUpdate()
 {
     if ($this->skipTrial) {
         return 'now';
     }
     return $this->trialEnd ? $this->trialEnd->getTimestamp() : null;
 }
开发者ID:rinodung,项目名称:hello-video-laravel,代码行数:12,代码来源:StripeGateway.php

示例3: diffInDates

 public static function diffInDates(Carbon $date1, Carbon $date2)
 {
     $date1ToSeconds = $date1->getTimestamp();
     $date2ToSeconds = $date2->getTimestamp();
     $difference = $date1ToSeconds - $date2ToSeconds;
     return self::differenceToTime($difference);
 }
开发者ID:brightantwiboasiako,项目名称:biddingapp,代码行数:7,代码来源:MediDateTime.php

示例4: extract

 /**
  * {@inheritdoc}
  *
  * @return int
  */
 public function extract($model)
 {
     $value = parent::extract($model);
     if ($value === null) {
         return null;
     }
     if (!$value instanceof Carbon) {
         $value = new Carbon($value);
     }
     return $value->getTimestamp();
 }
开发者ID:guratr,项目名称:cruddy,代码行数:16,代码来源:DateTime.php

示例5: registerMarkupTags

 /**
  * Registers CMS markup tags introduced by this plugin.
  *
  * @return  array
  */
 public function registerMarkupTags()
 {
     return ['filters' => ['strftime' => function ($time, $format) {
         static $locale;
         if (!$locale) {
             $locale = Lang::getLocale();
             Carbon::setLocale($locale);
             setlocale(LC_TIME, sprintf('%s_%s.UTF-8', $locale, strtoupper($locale)));
         }
         if (!$time instanceof Carbon) {
             $time = new Carbon($time);
         }
         return strftime($format, $time->getTimestamp());
     }]];
 }
开发者ID:anqqa,项目名称:oc-calendar-plugin,代码行数:20,代码来源:Plugin.php

示例6: getMtime

 /**
  *
  * Returns last post's published_at timestamp for current year
  * or $year/12/31 00:00:00 timestamp for other years
  *
  * @param $year
  * @return int
  */
 protected static function getMtime($year)
 {
     if ($year == date('Y')) {
         $post = BlogPost::orderBy('published_at', 'desc')->isPublished()->first();
         if ($post) {
             $date = new Carbon($post->published_at);
         } else {
             // if no posts, set date to the first of january
             $date = new Carbon();
             $date->setDateTime(date('Y'), 1, 1, 0, 0, 0);
         }
     } else {
         // previous year
         $date = new Carbon();
         $date->setDateTime($year, 12, 31, 0, 0, 0);
     }
     return $date->getTimestamp();
 }
开发者ID:graker,项目名称:blogarchive,代码行数:26,代码来源:ArchiveTrait.php

示例7: serialize

 /**
  * Serialize SharePoint Access Token
  *
  * @access  public
  * @return  string
  */
 public function serialize()
 {
     return serialize([$this->token, $this->expires->getTimestamp(), $this->expires->getTimezone()->getName()]);
 }
开发者ID:aroberson,项目名称:sharepoint-oauth-app-client,代码行数:10,代码来源:SPAccessToken.php

示例8: registerMarkupTags

 /**
  * Add Twig extensions
  *
  * @see Text extensions http://twig.sensiolabs.org/doc/extensions/text.html
  * @see Intl extensions http://twig.sensiolabs.org/doc/extensions/intl.html
  * @see Array extension http://twig.sensiolabs.org/doc/extensions/array.html
  * @see Time extension http://twig.sensiolabs.org/doc/extensions/date.html
  *
  * @return array
  */
 public function registerMarkupTags()
 {
     $twig = App::make('twig.environment');
     $filters = [];
     // add Text extensions
     $textExtension = new \Twig_Extensions_Extension_Text();
     $textFilters = $textExtension->getFilters();
     $filters += ['truncate' => function ($value, $length = 30, $preserve = false, $separator = '...') use($twig, $textFilters) {
         $callable = $textFilters['0']->getCallable();
         return $callable($twig, $value, $length, $preserve, $separator);
     }, 'wordwrap' => function ($value, $length = 80, $separator = "\n", $preserve = false) use($twig, $textFilters) {
         $callable = $textFilters['1']->getCallable();
         return $callable($twig, $value, $length, $separator, $preserve);
     }];
     // add Intl extensions if php5-intl installed
     if (class_exists('IntlDateFormatter')) {
         $intlExtension = new \Twig_Extensions_Extension_Intl();
         $intlFilters = $intlExtension->getFilters();
         $filters += ['localizeddate' => function ($date, $dateFormat = 'medium', $timeFormat = 'medium', $locale = null, $timezone = null, $format = null) use($twig, $intlFilters) {
             $callable = $intlFilters['0']->getCallable();
             return $callable($twig, $date, $dateFormat, $timeFormat, $locale, $timezone, $format);
         }, 'localizednumber' => function ($number, $style = 'decimal', $type = 'default', $locale = null) use($twig, $intlFilters) {
             $callable = $intlFilters['1']->getCallable();
             return $callable($twig, $number, $style, $type, $locale);
         }, 'localizedcurrency' => function ($number, $currency = null, $locale = null) use($twig, $intlFilters) {
             $callable = $intlFilters['2']->getCallable();
             return $callable($twig, $number, $currency, $locale);
         }];
     }
     // add Array extensions
     $arrayExtension = new \Twig_Extensions_Extension_Array();
     $arrayFilters = $arrayExtension->getFilters();
     $filters += ['shuffle' => function ($array) use($twig, $arrayFilters) {
         $callable = $arrayFilters['0']->getCallable();
         return $callable($twig, $array);
     }];
     // add Time extensions
     $timeExtension = new \Twig_Extensions_Extension_Date();
     $timeFilters = $timeExtension->getFilters();
     $filters += ['time_diff' => function ($date, $now = null) use($twig, $timeFilters) {
         $callable = $timeFilters['0']->getCallable();
         return $callable($twig, $date, $now);
     }];
     // add PHP functions
     $filters += ['strftime' => function ($time, $format = '%d.%m.%Y %H:%M:%S') {
         $timeObj = new Carbon($time);
         return strftime($format, $timeObj->getTimestamp());
     }, 'uppercase' => function ($string) {
         return strtoupper($string);
     }, 'lowercase' => function ($string) {
         return strtolower($string);
     }, 'ucfirst' => function ($string) {
         return ucfirst($string);
     }, 'lcfirst' => function ($string) {
         return lcfirst($string);
     }, 'ltrim' => function ($string, $charlist = " \t\n\r\v") {
         return ltrim($string, $charlist);
     }, 'rtrim' => function ($string, $charlist = " \t\n\r\v") {
         return rtrim($string, $charlist);
     }, 'str_repeat' => function ($string, $multiplier = 1) {
         return str_repeat($string, $multiplier);
     }, 'plural' => function ($string, $count = 2) {
         return str_plural($string, $count);
     }];
     return ['filters' => $filters];
 }
开发者ID:fuunnx,项目名称:loveandzucchini,代码行数:76,代码来源:Plugin.php

示例9: isInRange

 /**
  *
  * Checks if current date in in range of ($first_date:time())
  *
  * @return bool
  */
 protected function isInRange()
 {
     $first_date = self::getFirstDate();
     if (!$this->month) {
         $first_date->month(1);
     }
     if (!$this->day) {
         $first_date->day(1);
     }
     $now = new Carbon();
     $year = $this->year;
     $month = !$this->month ? '1' : $this->month;
     $day = !$this->day ? '1' : $this->day;
     $current = new Carbon();
     $current->setDate($year, $month, $day);
     $current->setTime(0, 0);
     return $first_date->getTimestamp() <= $current->getTimestamp() && $current->getTimestamp() <= $now->getTimestamp();
 }
开发者ID:graker,项目名称:blogarchive,代码行数:24,代码来源:BlogArchive.php

示例10: fullmix

 public function fullmix($dateType, $timeType, Carbon $carbon)
 {
     $fmt = new IntlDateFormatter($this->langCode, $this->getType($dateType), $this->getType($timeType), $carbon->tz);
     return $fmt->format($carbon->getTimestamp());
 }
开发者ID:carlos-ea,项目名称:laravel-date-international,代码行数:5,代码来源:DateIntlBuilder.php

示例11: formatDate

 protected function formatDate(Carbon $date)
 {
     return ['rfc3339' => $date->toRfc3339String(), 'timestamp' => $date->getTimestamp(), 'diffForHumans' => $date->diffForHumans()];
 }
开发者ID:SocietyCMS,项目名称:Documents,代码行数:4,代码来源:ObjectTransformer.php

示例12: postPause

 public function postPause($stream)
 {
     $time = Input::get('time');
     $date = new Carbon($time);
     $series = AnnouncementSeries::find($stream);
     $series->paused_until = $date;
     $series->save();
     $this->broadcast(array('stream' => $series, 'type' => 'pause', 'date' => $date->getTimestamp()));
 }
开发者ID:fencer-md,项目名称:stoticlle,代码行数:9,代码来源:AnnouncementsController.php

示例13: timestamp

 /**
  * Set the timestamp.
  *
  * @param  Carbon  $timestamp
  * @return $this
  */
 public function timestamp(Carbon $timestamp)
 {
     $this->timestamp = $timestamp->getTimestamp();
     return $this;
 }
开发者ID:illuminate,项目名称:notifications,代码行数:11,代码来源:SlackAttachment.php

示例14: getReadableSort

 /**
  * {@inheritDoc}
  */
 public function getReadableSort()
 {
     return $this->date->getTimestamp();
 }
开发者ID:webcomm,项目名称:reader,代码行数:7,代码来源:Story.php

示例15: setupDayPager

 /**
  * Sets up pager to switch prev/next day
  */
 protected function setupDayPager()
 {
     $first_date = $this->first_date;
     $current_date = $this->current_date;
     // previous
     if ($first_date->getTimestamp() < $current_date->getTimestamp()) {
         $previous_date = $current_date->copy();
         $previous_date->subDay(1);
         $this->previous_text = $previous_date->formatLocalized('%d') . ' ' . $previous_date->formatLocalized('%B') . ', ' . $previous_date->year;
         $this->previous_url = $this->makePagerUrl(array('year' => $previous_date->year, 'month' => $previous_date->month, 'day' => $previous_date->day));
     } else {
         $this->previous_text = $current_date->formatLocalized('%d') . ' ' . $current_date->formatLocalized('%B') . ', ' . $current_date->year;
         $this->previous_url = '';
     }
     // next
     $today = new Carbon();
     $today->setTime(0, 0);
     if ($this->current_date->getTimestamp() < $today->getTimestamp()) {
         $next_date = $current_date->copy();
         $next_date->addDay(1);
         $this->next_text = $next_date->formatLocalized('%d') . ' ' . $next_date->formatLocalized('%B') . ', ' . $next_date->year;
         $this->next_url = $this->makePagerUrl(array('year' => $next_date->year, 'month' => $next_date->month, 'day' => $next_date->day));
     } else {
         $this->next_text = $current_date->formatLocalized('%d') . ' ' . $current_date->formatLocalized('%B') . ', ' . $current_date->year;
         $this->next_url = '';
     }
 }
开发者ID:graker,项目名称:blogarchive,代码行数:30,代码来源:ArchivePager.php


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