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


PHP Carbon::setTimezone方法代码示例

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


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

示例1: getDt

 /**
  * Returns an instance of our DateTime object
  * @return \Carbon\Carbon
  */
 public function getDt()
 {
     if (is_null($this->dt)) {
         $this->dt = new Carbon();
         $this->dt->setTimezone($this->getTz());
     }
     return $this->dt;
 }
开发者ID:hhgr,项目名称:hhgolf,代码行数:12,代码来源:DateTime.php

示例2: update

 public function update(Request $request, $id)
 {
     $session_id = Session::getId();
     if (!$session_id) {
         return response('', 400);
     }
     $this->validate($request, ['id' => 'required|integer']);
     $bookmark = Bookmark::find($id);
     if ($request->bookmark) {
         $bookmark->bookmark = $request->bookmark;
         $bookmark->save();
     }
     if ($request->bookmarked_at) {
         $bookmarked_at = new Carbon($request->bookmarked_at, auth()->user()->timezone);
         $bookmarked_at->setTimezone('UTC');
         $bookmark->bookmarked_at = $bookmarked_at->toDateTimeString();
         $bookmark->save();
     }
     return response('', 204);
 }
开发者ID:gitstashgithub,项目名称:rating,代码行数:20,代码来源:BookmarkController.php

示例3: ended_past

 /**
  * Ended in the past.
  *
  * @since  3.0.0
  *
  * @return bool
  */
 public function ended_past()
 {
     return !is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isPast() : false;
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:11,代码来源:event.php

示例4: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update(UpdateEventRequest $req, $slug)
 {
     $input = $req->all();
     // Ensures database times are always in UTC.
     foreach ($input as $key => $value) {
         // Ensures only time fields are changed.
         if (!strpos($key, 'time')) {
             continue;
         }
         // Converts time from PST to UTC.
         $pst = new Carbon($value, 'America/Los_Angeles');
         $utc = $pst->setTimezone('UTC');
         // Sets date/time string back into values for database.
         $input[$key] = $utc->toDateTimeString();
     }
     Event::findBySlug($slug)->update($input);
     return redirect()->action('EventsController@show', $slug);
 }
开发者ID:natalieduong,项目名称:konnection,代码行数:24,代码来源:EventsController.php

示例5: ivy_echo_date

function ivy_echo_date(\Carbon\Carbon $date)
{
    $date->setTimezone(config('params.user_timezone'));
    return $date->isToday() ? 'Mới @' . $date->format(config('params.user_hourformat')) : ($date->isYesterday() ? 'Hôm qua @' . $date->format(config('params.user_hourformat')) : $date->format(config('params.user_dateformat')));
}
开发者ID:nguyenthuyenlong1988,项目名称:f1-cchouse,代码行数:5,代码来源:helpers.php

示例6: rawLogEntriesTable

 /**
  * Get raw entries with a selected set of values to grab.
  */
 public function rawLogEntriesTable()
 {
     $title = 'Raw log entries';
     $fields = Config::get('marauder.rawLogEntries');
     // all of the users log entries:
     $get = ['log_entries.id', 'structures.time_zone', 'log_entries.time', 'devices.name'];
     $query = LogEntry::leftJoin('devices', 'devices.id', '=', 'log_entries.device_id')->leftJoin('structures', 'structures.id', '=', 'devices.structure_id')->where('structures.user_id', Auth::user()->id)->take(Config::get('marauder.logTableLimit'))->orderBy('time', 'DESC')->orderBy('devices.id', 'ASC');
     // ignore stuff from the query:
     $ignore = ['id', 'time_zone'];
     foreach ($fields as $field) {
         $query->withLogValue($field);
         $get[] = $field . '.value as ' . $field;
     }
     $result = $query->get($get);
     if ($result->count() > 0) {
         $result = $result->toArray();
     }
     foreach ($result as $key => $entry) {
         foreach ($entry as $name => $value) {
             if ($name == 'time') {
                 // time zone correction!
                 $value = new Carbon($value, 'UTC');
                 $timezone = strlen($result[$key]['time_zone']) > 0 ? $result[$key]['time_zone'] : 'Europe/Amsterdam';
                 $value->setTimezone($timezone);
             }
             $result[$key][$name] = Format::format($name, $value);
         }
     }
     return View::make('raw.table', compact('result', 'ignore', 'title'));
 }
开发者ID:JC5,项目名称:marauder,代码行数:33,代码来源:TableController.php

示例7: getYahooWeatherInfo

 /**
  * Gets the weather from Yahoo!, which is more reliable.
  */
 public function getYahooWeatherInfo()
 {
     echo "<pre>\n";
     $manualSearch = new Collection();
     foreach (Structure::get() as $structure) {
         if (strlen($structure->postal_code) > 0 && strlen($structure->country_code) > 0) {
             // find City in database?
             /** @var City $city */
             $city = City::firstOrCreate(['postal_code' => $structure->postal_code, 'country_code' => $structure->country_code]);
         } else {
             // Fall back to Utrecht, the netherlands (central station area):
             $city = City::firstOrCreate(['postal_code' => '3511CE', 'country_code' => 'NL']);
         }
         $manualSearch->push($city);
     }
     $manualSearch = $manualSearch->unique();
     // Yahoo weather is always per city.
     /** @var City $manualEntry */
     foreach ($manualSearch as $city) {
         // function wont do stuff when its already filled.
         $this->_helper->getGeoFromYahoo($city);
         $weatherObject = $this->_helper->getYahooWeatherForCity($city);
         echo 'Now searching for city #' . $city->id . ', [postal code: ' . $city->postal_code . ', country code: ' . $city->country_code . ']' . "\n";
         echo 'City has timezone ' . $city->time_zone . ' and woe-id ' . $city->woeid . "\n";
         // try to get as many results from this as possible
         if (isset($weatherObject->query->results)) {
             $channel = $weatherObject->query->results->channel;
             // create report entry first:
             $report = new Report();
             $report->city()->associate($city);
             $report->time = new Carbon();
             $report->save();
             // start saving data:
             // sunrise:
             $sysSunrise = new Carbon($channel->astronomy->sunrise, $city->time_zone);
             $sysSunrise->setTimezone('UTC');
             $entry = new ReportValue();
             $entry->report()->associate($report);
             $entry->name = 'sys.sunrise';
             $entry->value = $sysSunrise->format('U');
             $entry->save();
             // sunset:
             $sysSunset = new Carbon($channel->astronomy->sunset, $city->time_zone);
             $sysSunset->setTimezone('UTC');
             $entry = new ReportValue();
             $entry->report()->associate($report);
             $entry->name = 'sys.sunset';
             $entry->value = $sysSunset->format('U');
             $entry->save();
             // current temperature:
             $entry = new ReportValue();
             $entry->report()->associate($report);
             $entry->name = 'main.temp';
             $entry->value = floatval($channel->item->condition->temp);
             $entry->save();
             // current humidity:
             $entry = new ReportValue();
             $entry->report()->associate($report);
             $entry->name = 'main.humidity';
             $entry->value = floatval($channel->atmosphere->humidity);
             $entry->save();
             // current pressure:
             $entry = new ReportValue();
             $entry->report()->associate($report);
             $entry->name = 'main.pressure';
             $entry->value = floatval($channel->atmosphere->pressure);
             $entry->save();
             // max predicted for today.
             $entry = new ReportValue();
             $entry->report()->associate($report);
             $entry->name = 'main.temp_max';
             $entry->value = floatval($channel->item->forecast[0]->high);
             $entry->save();
             // min predicted for today.
             $entry = new ReportValue();
             $entry->report()->associate($report);
             $entry->name = 'main.temp_min';
             $entry->value = floatval($channel->item->forecast[0]->low);
             $entry->save();
             // wind speed
             $entry = new ReportValue();
             $entry->report()->associate($report);
             $entry->name = 'wind.speed';
             $entry->value = floatval($channel->wind->speed);
             $entry->save();
             // wind degrees
             $entry = new ReportValue();
             $entry->report()->associate($report);
             $entry->name = 'wind.deg';
             $entry->value = floatval($channel->wind->direction);
             $entry->save();
             // rain 1h? SKIPPED
             // weather.main
             $entry = new ReportValue();
             $entry->report()->associate($report);
             $entry->name = 'weather.main';
             $entry->value = trim($channel->item->condition->text);
//.........这里部分代码省略.........
开发者ID:JC5,项目名称:marauder,代码行数:101,代码来源:CronController.php

示例8: convertToUTC

 /**
  * convert carbon date to UTC timezone
  *
  * @param \Carbon\Carbon $date
  *
  * @return static
  */
 public static function convertToUTC(Carbon $date)
 {
     return $date->setTimezone('UTC');
 }
开发者ID:vinelab,项目名称:agency,代码行数:11,代码来源:Helper.php


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