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


PHP Carbon::createFromTimeStamp方法代码示例

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


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

示例1: store

 /**
  * Attribution pixel
  *
  * @param  PixelRequest $request
  * @return Image
  */
 public function store(PixelRequest $request)
 {
     $this->agent->setUserAgent($request->header('user-agent'));
     ignore_user_abort(true);
     // Turn off gzip compression
     if (function_exists('apache_setenv')) {
         apache_setenv('no-gzip', 1);
     }
     ini_set('zlib.output_compression', 0);
     // Turn on output buffering if necessary
     if (ob_get_level() == 0) {
         ob_start();
     }
     // Remove any content encoding
     header('Content-encoding: none', true);
     if (!$request->isMethod('post')) {
         // Create attribution entry
         $attribution = Attribution::create(['landing_page_id' => $request->get('lp'), 'email' => $request->get('em'), 'tracking_id' => $request->get('t'), 'converting_source' => $request->get('cs'), 'converting_medium' => $request->get('cm'), 'converting_keyword' => $request->get('ck'), 'converting_content' => $request->get('ccn'), 'converting_campaign' => $request->get('cc'), 'converting_landing_page' => $request->get('cl'), 'converting_timestamp' => Carbon::createFromTimeStamp($request->get('ct'))->toDateTimeString(), 'original_source' => $request->get('os'), 'original_medium' => $request->get('om'), 'original_keyword' => $request->get('ok'), 'original_content' => $request->get('ocn'), 'original_campaign' => $request->get('oc'), 'original_landing_page' => $request->get('ol'), 'original_timestamp' => Carbon::createFromTimeStamp($request->get('ot'))->toDateTimeString(), 'refer_url' => $request->get('r'), 'platform' => $this->agent->platform(), 'device' => $this->agent->device(), 'browser' => $this->agent->browser(), 'version' => $this->agent->version($this->agent->browser())]);
         // Link attribution entry to lead
         \Event::fire(new AttributionSubmitted($attribution));
         // Return 1x1 pixel transparent gif
         header("Content-type: image/gif");
         header("Content-Length: 42");
         header("Cache-Control: private, no-cache, no-cache=Set-Cookie, proxy-revalidate");
         header("Pragma: no-cache");
         echo base64_decode('R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEA');
     }
     // Flush output buffers
     ob_flush();
     flush();
     ob_end_flush();
 }
开发者ID:henrytung,项目名称:Bodie-CRM,代码行数:38,代码来源:AttributionController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  * POST /actions
  *
  * @return Response
  */
 public function store()
 {
     $response = new stdClass();
     $statusCode = 201;
     $in = Input::only('tid', 'created_at');
     $rules = array('tid' => 'required | integer');
     $vd = Validator::make($in, $rules);
     if ($vd->fails()) {
         $errs = $vd->messages();
         $statusCode = 400;
         $response = $errs->all();
     } else {
         $authId = Auth::user()->id;
         // 先檢查是否在 Target 有登記
         $uid = Target::where(array('id' => $in['tid'], 'uid' => $authId))->pluck('uid');
         // 取得使用者的教會
         $cid = UserChurch::where(array('uid' => $authId))->pluck('cid');
         if ($uid == $authId) {
             $in['uid'] = Auth::user()->id;
             $in['cid'] = $cid;
             $action = Action::create($in);
             if ($in['created_at']) {
                 $in['created_at'] = Carbon::createFromTimeStamp($in['created_at'], 'Asia/Taipei')->toDateTimeString();
                 $action->setCreatedAt($in['created_at']);
                 $action->save();
             }
         } else {
             $statusCode = 403;
         }
     }
     return Response::json($response, $statusCode);
 }
开发者ID:htchien,项目名称:prayerweb,代码行数:38,代码来源:ActionsController.php

示例3: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->info('');
     $this->info('------------------------------------------');
     $this->info('');
     $feeds = Feeds::all();
     foreach ($feeds as $f) {
         $feed = SimpleFeeds::make($f->url);
         $count = 0;
         $story['source'] = $feed->get_title();
         $story['source_url'] = $feed->get_permalink();
         foreach ($feed->get_items() as $item) {
             $date = strtotime($item->get_date());
             // $dom = new \Htmldom($item->get_permalink());
             // echo $response->getBody();
             $story['headline'] = $item->get_title();
             $story['url'] = $item->get_permalink();
             $story['feed_id'] = $f->id;
             // $story['image'] = (isset($item->get_thumbnail())) ? $item->get_thumbnail() : '';
             // $story['excerpt'] = (isset($dom->find($f->excerpt)[0]->find('p')[0])) ? $dom->find($f->excerpt)[0]->find('p')[0]->plaintext : 'empty';
             $story['pub_date'] = Carbon::createFromTimeStamp($date)->format('Y-m-d G:i');
             if ($item->get_description() && $f->use_description) {
                 $story['excerpt'] = $item->get_description();
                 $story['approved'] = true;
             }
             if (!Stories::where('headline', '=', $story['headline'])->first()) {
                 Stories::create($story);
                 $count++;
             }
         }
         $this->info('Added ' . $count . ' stories from ' . $f->name);
     }
 }
开发者ID:ericmller29,项目名称:thesportsnews,代码行数:38,代码来源:NewsUpdate.php

示例4: data

 /**
  * @param $data
  * @return mixed
  */
 public function data($data, $parameters = [])
 {
     if (is_numeric($data)) {
         return Carbon::createFromTimeStamp($data);
     }
     return '';
 }
开发者ID:coandacms,项目名称:coanda-core,代码行数:11,代码来源:Date.php

示例5: index

 public static function index()
 {
     $feeds = Feeds::all();
     $stories = [];
     foreach ($feeds as $f) {
         $feed = SimpleFeeds::make($f->url);
         $count = 0;
         $story['source'] = $feed->get_title();
         $story['source_url'] = $feed->get_permalink();
         foreach ($feed->get_items() as $item) {
             $date = strtotime($item->get_date());
             // $dom = new \Htmldom($item->get_permalink());
             // echo $response->getBody();
             $story['headline'] = $item->get_title();
             $story['url'] = $item->get_permalink();
             $story['feed_id'] = $f->id;
             // $story['image'] = (isset($item->get_thumbnail())) ? $item->get_thumbnail() : '';
             // $story['excerpt'] = (isset($dom->find($f->excerpt)[0]->find('p')[0])) ? $dom->find($f->excerpt)[0]->find('p')[0]->plaintext : 'empty';
             $story['pub_date'] = Carbon::createFromTimeStamp($date)->format('Y-m-d G:i');
             if (!Stories::where('headline', '=', $story['headline'])->first()) {
                 $stories[] = $story;
                 Stories::create($story);
                 $count++;
             }
         }
     }
     usort($stories, function ($a, $b) {
         $t1 = strtotime($a['pub_date']);
         $t2 = strtotime($b['pub_date']);
         return $t2 - $t1;
     });
     return response()->json($stories);
 }
开发者ID:ericmller29,项目名称:thesportsnews,代码行数:33,代码来源:Reader.php

示例6: data

 /**
  * @param $data
  * @return mixed
  */
 public function data($data, $parameters = [])
 {
     if (is_numeric($data)) {
         return Carbon::createFromTimeStamp($data)->format(Config::get('coanda::coanda.datetime_format'));
     }
     return '';
 }
开发者ID:coandacms,项目名称:coanda-core,代码行数:11,代码来源:DateTime.php

示例7: retrieve

 public function retrieve(Request $request, Weather $weather)
 {
     if (!$request->has('lat') || !$request->has('lon')) {
         return response('Please provide a lat and lon', 400);
     }
     $input = $request->all();
     // We grab the lat and lon
     $lat = $input['lat'];
     $lon = $input['lon'];
     // We grab the latest data from this lat and long
     $rawData = file_get_contents('http://api.openweathermap.org/data/2.5/weather?lat=' . $lat . '&lon=' . $lon);
     if (!$rawData) {
         // We failed to retrieve data from the webservice
         // Just return the stuff we have
         return $weather->where('lat', $lat)->where('lon', $lon)->limit(10)->get();
     }
     $jsonData = json_decode($rawData, true);
     // We transform this data
     $data = ['dt' => $jsonData['dt'], 'lat' => $lat, 'lon' => $lon, 'type' => $jsonData['weather'][0]['main'], 'temp' => $jsonData['main']['temp'] - 273.15];
     // Check if we already have a record with same lat/lon and dt in our database
     $weatherCheck = $weather->where('lat', $lat)->where('lon', $lon)->where('dt', Carbon::createFromTimeStamp($data['dt']))->limit(1)->get();
     // Record isn't in our db yet
     if ($weatherCheck->isEmpty()) {
         // We store the data in our database
         $weather->create($data);
     }
     // We grab the last 10 weather report from given lat/lon and return it
     return $weather->where('lat', $lat)->where('lon', $lon)->limit(10)->get();
 }
开发者ID:Boydbueno,项目名称:weatherStore,代码行数:29,代码来源:WeatherController.php

示例8: date

 /**
  * Present the start date.
  *
  * @param string $type short|medium|long
  * @return string
  */
 public function date(string $type = 'long')
 {
     // $now = \Carbon\Carbon::createFromTimeStamp(strtotime(\Carbon\Carbon::now('America/New_York')));
     // $start = \Carbon\Carbon::createFromTimeStamp(strtotime($this->model->start_at));
     // $diffForHumans =  $start->diffForHumans($now);
     // $diffForHumans = str_replace(['before', 'after'], ['ago', 'from now'], $diffForHumans);
     $timestamp = strtotime($this->model->start_at);
     $carbon = Carbon::createFromTimeStamp($timestamp);
     $date = date('l, F j, Y', $timestamp);
     $humanDay = null;
     if ($carbon->isToday()) {
         $humanDay = 'Today';
     } elseif ($carbon->isTomorrow()) {
         $humanDay = 'Tomorrow';
     } elseif ($carbon->isYesterday()) {
         $humanDay = 'Yesterday';
     }
     switch ($type) {
         case 'short':
             return $humanDay ?: $date;
         case 'medium':
             return $date;
         case 'long':
         default:
             return $humanDay ? $humanDay . ', ' . $date : $date;
     }
 }
开发者ID:slicvic,项目名称:wgg,代码行数:33,代码来源:EventPresenter.php

示例9: sitemap

 /**
  * Handle requests for '/sitemap.xml'.
  *
  * @return \Illuminate\Http\Response
  *
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  */
 public function sitemap()
 {
     if (!$this->wp->isPublic()) {
         abort(404);
     }
     $view = view('root.sitemap', ['appModified' => Carbon::createFromTimeStamp(app('modified'), $this->wp->timezone())]);
     return response($view, 200, ['content-type' => 'text/xml']);
 }
开发者ID:hrslash,项目名称:luminous,代码行数:15,代码来源:RootController.php

示例10: createDateAntlers

function createDateAntlers($date)
{
    $timeArray = explode(' ', $date);
    $month = $timeArray[0];
    $day = rtrim($timeArray[1], ',');
    $year = $timeArray[2];
    $timestamp = strtotime($day . " " . $month . " " . $year);
    return $date = Carbon::createFromTimeStamp($timestamp);
}
开发者ID:kcunanan,项目名称:claremontrise,代码行数:9,代码来源:ScraperController.php

示例11: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     //  Shop::truncate();
     $startDate = Carbon::createFromTimeStamp($faker->dateTimeBetween('-1 years', '+1 month')->getTimestamp());
     foreach (range(1, 20) as $index) {
         Shop::create(['name' => $faker->name, 'shopDescription' => $faker->realText($maxNbChars = 200, $indexSize = 2), 'location' => $faker->city, 'contactNumber' => $faker->phoneNumber, 'openingDate' => $startDate->toDateTimeString(), 'email' => $faker->companyEmail]);
     }
 }
开发者ID:zekaroz,项目名称:Opel,代码行数:14,代码来源:ShopsSeeder.php

示例12: printWeekOrders

 /**
  * @Middleware("admin")
  * @Get("/print/week")
  */
 public function printWeekOrders()
 {
     $week = \Input::get('week');
     $date = Carbon::createFromTimeStamp($week);
     $dateFormatted = $date->copy()->format('d.m.Y');
     $dateFormatted2 = $date->copy()->addDays(4)->format('d.m.Y');
     $users = User::getWeekPrintData($date);
     return view('admin.orders.print-week', compact('users', 'dateFormatted', 'dateFormatted2'));
 }
开发者ID:petarslovic,项目名称:web-hungry,代码行数:13,代码来源:OrderController.php

示例13: updated_at

 public function updated_at()
 {
     $timestamp = strtotime($this->updated_at);
     if (time() < $timestamp + 86400 * 3) {
         return \Carbon\Carbon::createFromTimeStamp(strtotime($this->updated_at))->diffForHumans();
     } else {
         return $this->updated_at;
     }
 }
开发者ID:sea-watch,项目名称:sea-watch-app,代码行数:9,代码来源:emergencyCase.php

示例14: handleInvoicePaymentFailed

 /**
  * Handle a failed payment from a Stripe invoice.
  *
  * @param array $payload
  * 
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function handleInvoicePaymentFailed(array $payload)
 {
     if ($customer = $this->getCustomer($payload['data']['object']['customer'])) {
         $next_attempt = Arr::get($payload, 'data.object.next_payment_attempt');
         $data = array('attempt_count' => Arr::get($payload, 'data.object.attempt_count'), 'next_attempt' => Carbon::createFromTimeStamp($next_attempt));
         $customer->fireCustomerEvent('invoicePaymentFailed', $customer->invoices()->find($payload['data']['object']['id']), $data);
     }
     return new Response('Webhook Handled', 200);
 }
开发者ID:autocar,项目名称:laravel-billing,代码行数:16,代码来源:WebhookController.php

示例15: postHelpCreate

 public function postHelpCreate($_timestamp = 0)
 {
     //return Input::all();
     $reslove_type = Input::get('reslove_type');
     $workbench = Input::get('workbench');
     $timestamp = Crypt::decrypt($_timestamp);
     $dept_id = DB::table('tb_sub_dept')->where('sub_dept_id', '=', Input::get('sub_dept_id'))->pluck('dept_id');
     //Input::all();
     $helpdesk = new Helpdesk();
     $helpdesk->help_description = Input::get('help_description');
     $helpdesk->helpdesk_type_id = Input::get('ruin_type_id');
     $helpdesk->symptom_id = Input::get('symptoms_id');
     $helpdesk->dept_id = $dept_id;
     $helpdesk->sub_dept_id = Input::get('sub_dept_id');
     $helpdesk->help_date = date('Y-m-d H:i:s');
     if ($timestamp > 0) {
         $helpdesk->callcenter_date = \Carbon\Carbon::createFromTimeStamp($timestamp)->toDateTimeString();
     }
     $helpdesk->contact_name = Input::get('contact_name');
     $helpdesk->reslove_type = $reslove_type;
     $helpdesk->staff_id = Input::get('staff_id');
     $helpdesk->help_note = Input::get('help_note');
     $helpdesk->cause = null;
     $helpdesk->workbench = null;
     $helpdesk->help_result = Input::get('help_result');
     $helpdesk->forward_type = Input::get('forward_type');
     $helpdesk->helpdesk_web_type = 1;
     $helpdesk->is_notify = 1;
     if ($reslove_type == '1') {
         $helpdesk->cause = Input::get('cause');
     } else {
         if ($reslove_type == '2') {
             $helpdesk->workbench = $workbench;
         }
     }
     $helpdesk->save();
     if ($reslove_type == '2') {
         switch ($workbench) {
             case "1":
                 $redirect = "helpdesk/help-fix/" . Crypt::encrypt($helpdesk->id);
                 break;
             case "2":
                 $redirect = "helpdesk/help-list";
                 break;
             case "3":
                 $redirect = "helpdesk/help-list";
                 break;
             default:
                 $redirect = "helpdesk/help-list";
                 break;
         }
         return Redirect::to($redirect);
     }
     return Redirect::to('helpdesk/help-list');
 }
开发者ID:gitda,项目名称:inventory2,代码行数:55,代码来源:HelpdeskController.php


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