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


PHP Carbon::createFromTime方法代码示例

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


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

示例1: loginAction

 /**
  * @Route("/login", name="api_login")
  * @Method("POST")
  * @param Request $request
  * @return JsonResponse
  */
 public function loginAction(Request $request)
 {
     $userDTO = new ApiUserLogin();
     $form = $this->createForm(new LoginApiType(), $userDTO);
     $this->handleJsonForm($form, $request);
     $redmineClient = $this->get('redmine.guzzle_client');
     try {
         $redmineResponse = $redmineClient->redmineLogin($userDTO->getUsername(), $userDTO->getPassword());
         $q = json_decode($redmineResponse);
         /** @var EntityManager $em */
         $em = $this->getDoctrine()->getManager();
         $user = $em->getRepository("RedmineAppBundle:RedmineUser")->findOneBy(['redmineToken' => $q->user->api_key, 'redmineUserID' => $q->user->id]);
         if (!$user) {
             $passwordEncoder = $this->get('security.password_encoder');
             $user = new RedmineUser();
             $user->setUsername($q->user->login)->setEmail($q->user->mail)->setPassword($passwordEncoder->encodePassword($user, md5(uniqid())))->setName($q->user->firstname)->setSurname($q->user->lastname)->setRedmineUserID($q->user->id)->setRedmineToken($q->user->api_key);
             $settings = new Settings();
             $settings->setSms(false)->setPush(false)->setCheckFirst(Carbon::createFromTime(17, 45))->setCheckSecond(Carbon::createFromTime(20, 0))->setCheckThird(Carbon::createFromTime(9, 30))->setUser($user);
             $em->persist($user);
             $em->persist($settings);
             $em->flush();
         }
     } catch (\Exception $e) {
         return new JsonResponse(['message' => 'Redmine user: bad credentials'], 403);
     }
     $this->get('redmine.device.notification')->getDevice($user, $userDTO->getDeviceId(), $userDTO->getPushToken(), $userDTO->getPushPlatform());
     return new JsonResponse($user);
 }
开发者ID:ekreative,项目名称:redmine-time-tracker,代码行数:34,代码来源:LoginController.php

示例2: handle

 public function handle($request, Closure $next)
 {
     if ($this->auth->check()) {
         $this->auth->user()->update(['user_lastvisit' => Carbon::createFromTime(null, null, 0)]);
     }
     return $next($request);
 }
开发者ID:NiHikKi,项目名称:osu-web,代码行数:7,代码来源:UpdateUserLastvisit.php

示例3: authUserFromRedmine

 public function authUserFromRedmine(UsernamePasswordToken $token)
 {
     $pass = $token->getCredentials();
     $username = $token->getUser();
     try {
         $response = $this->client->redmineLogin($username, $pass);
         $q = json_decode($response);
         $em = $this->em;
         $user = $em->getRepository("RedmineAppBundle:RedmineUser")->findOneBy(['redmineToken' => $q->user->api_key, 'redmineUserID' => $q->user->id]);
         if ($user) {
             return $user->getUsername();
         } else {
             $user = new RedmineUser();
             $user->setUsername($q->user->login)->setEmail($q->user->mail)->setPassword($this->encoder->encodePassword($user, md5(uniqid())))->setName($q->user->firstname)->setSurname($q->user->lastname)->setRedmineUserID($q->user->id)->setRedmineToken($q->user->api_key);
             $settings = new Settings();
             $settings->setSms(false)->setPush(false)->setCheckFirst(Carbon::createFromTime(17, 45))->setCheckSecond(Carbon::createFromTime(20, 0))->setCheckThird(Carbon::createFromTime(9, 30))->setUser($user);
             $this->em->persist($user);
             $this->em->persist($settings);
             $this->em->flush();
             return $user->getUsername();
         }
     } catch (\Exception $e) {
         return null;
     }
 }
开发者ID:ekreative,项目名称:redmine-time-tracker,代码行数:25,代码来源:RedmineUserProvider.php

示例4: differenceUntilNow

 /**
  * @param $time
  * @return int
  */
 public static function differenceUntilNow($time)
 {
     $timerData = explode(':', $time);
     $hour = $timerData[0];
     $minute = $timerData[1];
     $second = $timerData[2];
     $timer = Carbon::createFromTime($hour, $minute, $second);
     $now = Carbon::now();
     return $now->diffInSeconds($timer);
 }
开发者ID:brightantwiboasiako,项目名称:biddingapp,代码行数:14,代码来源:MediDateTime.php

示例5: getHello

 public function getHello()
 {
     $hello = 'Hallo';
     if (Carbon::now() > Carbon::createFromTime(0, 0, 0) && Carbon::now() < Carbon::createFromTime(6, 0, 0)) {
         $hello = 'Guten Abend,';
     } elseif (Carbon::now() > Carbon::createFromTime(6, 0, 0) && Carbon::now() < Carbon::createFromTime(11, 0, 0)) {
         $hello = 'Guten Morgen,';
     } elseif (Carbon::now() > Carbon::createFromTime(11, 0, 0) && Carbon::now() < Carbon::createFromTime(13, 0, 0)) {
         $hello = 'Mahlzeit,';
     } elseif (Carbon::now() > Carbon::createFromTime(13, 0, 0) && Carbon::now() < Carbon::createFromTime(17, 0, 0)) {
         $hello = 'Schönen Nachmittag,';
     } elseif (Carbon::now() > Carbon::createFromTime(19, 0, 0) && Carbon::now() < Carbon::createFromTime(24, 0, 0)) {
         $hello = 'Guten Abend,';
     }
     return $hello;
 }
开发者ID:sewede,项目名称:footipp,代码行数:16,代码来源:SayHello.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(8, 00, 0, 'America/Mexico_City'), 'titulo' => 'Registro', 'descripcion' => '']);
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(8, 45, 0, 'America/Mexico_City'), 'titulo' => 'Presentación', 'descripcion' => '']);
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(9, 00, 0, 'America/Mexico_City'), 'titulo' => 'Entorno Económico', 'descripcion' => '']);
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(9, 40, 0, 'America/Mexico_City'), 'titulo' => 'Innovación en la cadena de valor: información y tecnología como elementos clave', 'descripcion' => '']);
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(9, 40, 0, 'America/Mexico_City'), 'titulo' => 'Agricultura sustentable: blue number initiative', 'descripcion' => '']);
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(9, 40, 0, 'America/Mexico_City'), 'titulo' => 'Información para el consumidor: tecnología y etiquetado', 'descripcion' => '']);
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(10, 35, 0, 'America/Mexico_City'), 'titulo' => 'Receso', 'descripcion' => '']);
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(11, 00, 0, 'America/Mexico_City'), 'titulo' => 'Innovación e internacionalización', 'descripcion' => '']);
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(11, 00, 0, 'America/Mexico_City'), 'titulo' => 'Dos casos exitosos de exportación mexicana: Aguacate y Tequila', 'descripcion' => '']);
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(12, 00, 0, 'America/Mexico_City'), 'titulo' => 'Receso', 'descripcion' => '']);
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(12, 30, 0, 'America/Mexico_City'), 'titulo' => 'Innovación en la industria', 'descripcion' => '']);
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(13, 40, 0, 'America/Mexico_City'), 'titulo' => 'Aperitivo y Comida', 'descripcion' => '']);
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(15, 30, 0, 'America/Mexico_City'), 'titulo' => 'Cooperación entre industria y gastronomía para la innovación', 'descripcion' => '']);
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(16, 30, 0, 'America/Mexico_City'), 'titulo' => 'Presentación de proyectos de investigación', 'descripcion' => '']);
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(16, 55, 0, 'America/Mexico_City'), 'titulo' => 'Receso', 'descripcion' => '']);
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(17, 25, 0, 'America/Mexico_City'), 'titulo' => 'Innovación en la experiencia del cliente', 'descripcion' => '']);
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(18, 30, 0, 'America/Mexico_City'), 'titulo' => 'Conclusiones y despedida', 'descripcion' => '']);
     DB::table('Presentacion')->insert(['idBloque' => 1, 'hora' => Carbon::createFromTime(18, 45, 0, 'America/Mexico_City'), 'titulo' => 'Coctel de despedida', 'descripcion' => '']);
     // $presentaciones = [ new cTalk('', '08:00', 'Registro', '',),
     //                     new cTalk('', '08:45', 'Presentación', '',),
     //                     new cTalk('', '09:00', 'Entorno Económico', '',),
     //                     new cTalk('', '09:40', '', '',),
     //                     new cTalk('', '10:35', '', '',),
     //                     new cTalk('', '11:00', '', '',),
     //                     new cTalk('', '12:00', '', '',),
     //                     new cTalk('', '12:30', '', '',),
     //                     new cTalk('', '13:40', '', '',),
     //                     new cTalk('', '15:30', '', '',),
     //                     new cTalk('', '16:30', '', '',),
     //                     new cTalk('', '16:55', '', '',),
     //                     new cTalk('', '17:25', '', '',),
     //                     new cTalk('', '18:30', '', '',),
     //                     new cTalk('', '18:45', '', '',),
     //                   ];
     // foreach ($presentaciones as $presentacion)
     // {
     //     DB::table('Presentacion')->insert
     //     ([
     //         'idBloque'    => $presentaciones->aBloque,
     //         'hora'        => $presentaciones->aHora,
     //         'titulo'      => $presentaciones->aTitulo,
     //         'descripcion' => $presentaciones->aDescripcion
     //     ]);
     // }
 }
开发者ID:lmgl9516,项目名称:EDI,代码行数:52,代码来源:PlanTableSeeder.php

示例7: getOpensLastWeek

 protected function getOpensLastWeek(MailTemplate $template)
 {
     $return = [];
     $emailOpens = new EmailOpens();
     $opens = $template->opens()->where($emailOpens->table . '.created_at', '>=', Carbon::now()->subWeek())->orderBy('created_at', 'asc')->get();
     // Set placeholder data
     for ($i = 0; $i < 7; $i++) {
         $date = Carbon::createFromTime(null, 0, 0)->subDays($i);
         $return[$date->day] = (object) ['ts' => $date, 'count' => 0];
     }
     // Set actual data
     foreach ($opens as $open) {
         $date = $open->created_at;
         $return[$date->day]->count += 1;
     }
     return $return;
 }
开发者ID:aydancoskun,项目名称:octobercms,代码行数:17,代码来源:Template.php

示例8: testSubSecondPassingArg

 public function testSubSecondPassingArg()
 {
     $this->assertSame(58, Carbon::createFromTime(0)->subSecond(2)->second);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:4,代码来源:SubTest.php

示例9: getTopicsQuery

 /**
  * {@inheritDoc}
  */
 protected function getTopicsQuery($sort, $direction)
 {
     // Get topics
     $topics = $this->model->select('users.slug as user_slug', 'users.username', 'lforums_topics.slug', 'lforums_topics.title', 'lforums_topics.created_at', 'lforums_topics.id', 'lforums_topics.updated_at', 'lforums_topics.views', 'lforums_topics.posts_count', 'lforums_topics.sticky', 'lforums_topics.locked', 'lforums_topics.last_post', 'last_user.slug as last_user_slug', 'last_user.username as last_user_username', 'lforums_topics.tag', 'lforums_topics.forum_id')->join('lforums_users as users', 'user_id', '=', 'users.id')->join('lforums_users as last_user', 'lforums_topics.last_post_user', '=', 'last_user.id')->whereNested(function ($query) {
         /** @var $query \Illuminate\Database\Query\Builder */
         $query->where('lforums_topics.expires_at', null)->orWhere('lforums_topics.expires_at', '>', Carbon::createFromTime());
     })->orderBy('lforums_topics.sticky', 'desc')->orderBy($sort, $direction);
     if (\Auth::check()) {
         $topics->with('read');
     }
     return $topics;
 }
开发者ID:kaamaru,项目名称:laravel-forums,代码行数:15,代码来源:EloquentTopicRepo.php

示例10: testAddSecond

 public function testAddSecond()
 {
     $this->assertSame(1, Carbon::createFromTime(0, 0, 0)->addSecond()->second);
 }
开发者ID:shinichi81,项目名称:laravel4demo,代码行数:4,代码来源:AddTest.php

示例11: function

<?php

/**
 * Dx
 *
 * @link http://dennesabing.com
 * @author Dennes B Abing <dennes.b.abing@gmail.com>
 * @license proprietary
 * @copyright Copyright (c) 2015 ClaremontDesign/MadLabs-Dx
 * @version 0.0.0.1
 * @since Mar 8, 2016 10:37:59 AM
 * @file widget.php
 * @project Expression project.name is undefined on line 13, column 15 in Templates/Scripting/EmptyPHP.php.
 * @package Expression package is undefined on line 14, column 15 in Templates/Scripting/EmptyPHP.php.
 *
 */
return ['type' => 'form', 'enable' => true, 'config' => ['access' => 'only::sudo', 'values' => ['default' => ['enable' => true, 'array' => function () {
    $details = zbase()->system()->scheduledDowntimeDetails();
    if (empty($details['maintenance-message'])) {
        $details['maintenance-message'] = 'We will be having a temporary downtime on {START_TIME} until {END_TIME}. We will be doing updates and maintenance to serve you better.';
        $details['start-datetime'] = \Carbon\Carbon::createFromTime(10, 0, 0);
        $details['end-datetime'] = \Carbon\Carbon::createFromTime(11, 0, 0);
    } else {
        $details['start-datetime'] = zbase_date_from_format('Y-m-d H:i:s', $details['start-datetime']);
        $details['end-datetime'] = zbase_date_from_format('Y-m-d H:i:s', $details['end-datetime']);
    }
    return $details;
}]], 'entity' => null, 'elements' => ['header' => ['ui' => ['type' => 'component.pageHeader', 'id' => 'header', 'text' => 'Maintenance Message Details']], 'status' => ['type' => 'select', 'id' => 'status', 'label' => 'Status', 'multiOptions' => 'enableDisable', 'help' => ['text' => 'Message will be displayed on the User Dashboard if Enabled.']], 'start-datetime' => ['type' => 'datetimelocal', 'id' => 'start-datetime', 'label' => 'Start Date/Time', 'help' => ['text' => 'Enter start date and time of maintenance.'], 'validations' => ['required' => ['enable' => true, 'message' => 'Enter start date and time of maintenance.']]], 'end-datetime' => ['type' => 'datetimelocal', 'id' => 'end-datetime', 'label' => 'End Date/Time', 'help' => ['text' => 'Enter end date and time of maintenance.'], 'validations' => ['required' => ['enable' => true, 'message' => 'Enter end date and time of maintenance.']]], 'maintenance-message' => ['type' => 'textarea', 'id' => 'maintenance-message', 'label' => 'Message prior to Maintenance', 'help' => ['text' => 'Message to be displayed to the user before the maintenance.'], 'html' => ['attributes' => ['input' => ['placeholder' => 'Enter Message']]]], 'maintenance-ips' => ['type' => 'textarea', 'id' => 'maintenance-ips', 'label' => 'IP Addresses to be excluded', 'help' => ['text' => 'Enter IP Address that will be excluded for the Maintenance. 1 IP Address per Line.'], 'html' => ['attributes' => ['input' => ['placeholder' => 'IP Addresses']]]]]]];
开发者ID:claremontdesign,项目名称:zbase,代码行数:28,代码来源:system-maintenance-form.php

示例12: getBalanceAttribute

 /**
  * @param $balance
  * @return object
  */
 public function getBalanceAttribute($balance)
 {
     // TODO: improve this method
     $balance -= $this->workload->diffInMinutes(Carbon::createFromTime(0, 0, 0));
     if (true === (bool) $this->arrival1 && true === (bool) $this->leaving1) {
         $balance += $this->arrival1->diffInMinutes($this->leaving1);
     }
     if (true === (bool) $this->arrival2 && true === (bool) $this->leaving2) {
         $balance += $this->arrival2->diffInMinutes($this->leaving2);
     }
     if (true === (bool) $this->arrival3 && true === (bool) $this->leaving3) {
         $balance += $this->arrival3->diffInMinutes($this->leaving3);
     }
     $sign = $balance < 0 ? '-' : '+';
     $sign = $balance == 0 ? null : $sign;
     $balance = Carbon::createFromTime(0, 0, 0)->addMinutes(abs($balance));
     return (object) ['value' => $balance, 'sign' => $sign];
 }
开发者ID:brnbp,项目名称:clockin,代码行数:22,代码来源:Workday.php

示例13: testSubSecond

 public function testSubSecond()
 {
     $this->assertSame(59, Carbon::createFromTime(0, 0, 0)->subSecond()->second);
 }
开发者ID:GeorgeBroadley,项目名称:caffeine-vendor,代码行数:4,代码来源:SubTest.php

示例14: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     foreach (range(1, 100) as $i) {
         DB::table('user_shifts')->insert(['user_id' => rand(2, 3), 'shift_id' => $i, 'start_time' => \Carbon\Carbon::createFromTime(8, 0, 0, 'America/New_York'), 'end_time' => \Carbon\Carbon::createFromTime(17, 0, 0, 'America/New_York')]);
     }
 }
开发者ID:samyerkes,项目名称:sweet.com,代码行数:11,代码来源:EmployeeShiftsTableSeeder.php

示例15: process

 public function process()
 {
     foreach ($this->xml->children() as $child) {
         if ($child->count() === 0) {
             continue;
         }
         $key = $child->value->array->data->value[0]->string->__toString();
         $value = $child->value->array->data->value[1]->string->__toString();
         switch ($key) {
             case 'UstId_1':
                 $this->ownUstId = (string) $value;
                 break;
             case 'UstId_2':
                 $this->foreignUstId = $value;
                 break;
             case 'Firmenname':
                 $this->companyName = $value;
                 break;
             case 'Erg_Name':
                 $this->responseCompanyName = $value;
                 break;
             case 'Strasse':
                 $this->street = $value;
                 break;
             case 'Erg_Str':
                 $this->responseStreet = $value;
                 break;
             case 'Ort':
                 $this->city = $value;
                 break;
             case 'Erg_Ort':
                 $this->responseCity = $value;
                 break;
             case 'PLZ':
                 $this->zipCode = $value;
                 break;
             case 'Erg_PLZ':
                 $this->responseZipCode = $value;
                 break;
             case 'Datum':
                 $arr = $this->_getDateTimeArray($value);
                 $this->date = Carbon::createFromDate($arr[2], $arr[1], $arr[0]);
                 break;
             case 'Uhrzeit':
                 $arr = $this->_getDateTimeArray($value, ':');
                 $this->time = Carbon::createFromTime($arr[0], $arr[1], $arr[2]);
                 break;
             case 'Gueltig_ab':
                 $arr = $this->_getDateTimeArray($value);
                 $this->validFrom = Carbon::createFromDate($arr[2], $arr[1], $arr[0]);
                 break;
             case 'Gueltig_bis':
                 $arr = $this->_getDateTimeArray($value);
                 $this->validUntil = Carbon::createFromDate($arr[2], $arr[1], $arr[0]);
                 break;
             case 'Druck':
                 $this->printConfirmation = $this->_getPrintConfirmationOption($value);
                 break;
             case 'ErrorCode':
                 $this->errorCode = (int) $value;
                 break;
         }
     }
     $this->_setErrorMessage((string) $this->errorCode);
 }
开发者ID:codedge,项目名称:laravel-bzst-evatr,代码行数:65,代码来源:EvatrXmlResponse.php


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