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


PHP Date::now方法代码示例

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


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

示例1: home

 public function home()
 {
     $page_title = "لوحة التحكم";
     $section_title = "لوحة التحكم";
     Date::setLocale('ar');
     $date = Date::now()->format('j F Y');
     $day = Date::now()->format('l');
     $month = Date::now()->format('F');
     $year = Date::now()->format('Y');
     //**************Tasks***************
     $tasksToday = Task::orderBy('task_date', 'desc')->today()->take(5);
     $tasksWeek = Task::orderBy('task_date', 'desc')->thisweek()->take(5);
     $tasksMonth = Task::orderBy('task_date', 'desc')->thisMonth()->take(5);
     $tasks_count = count($tasksToday->toArray());
     //**************Fails***************
     $failsToday = Failure::orderBy('fail_time', 'desc')->today()->take(5);
     $failsWeek = Failure::orderBy('fail_time', 'desc')->thisweek()->take(5);
     $failsMonth = Failure::orderBy('fail_time', 'desc')->thisMonth()->take(5);
     $fails_count = count($failsToday->toArray());
     //**************Repairs***************
     $repairsToday = Repair::today();
     $repairsWeek = Repair::thisweek();
     $repairsMonth = Repair::thisMonth();
     $repairs_count = count($repairsToday->toArray());
     return view('dashboard.dashboard', compact('page_title', 'section_title', 'date', 'day', 'month', 'year', 'tasksToday', 'tasksMonth', 'tasksWeek', 'tasks_count', 'failsToday', 'failsMonth', 'failsWeek', 'fails_count', 'repairsToday', 'repairsMonth', 'repairsWeek', 'repairs_count'));
 }
开发者ID:ashraf2033,项目名称:maintainit,代码行数:26,代码来源:PagesController.php

示例2: trash

 /**
  *
  */
 public function trash()
 {
     if ($this->isDeleted()) {
         return;
     }
     $this->deletedAt = Date::now();
 }
开发者ID:simonbowen,项目名称:lumen-doctrine,代码行数:10,代码来源:SoftDeletes.php

示例3: getInsert

 public function getInsert()
 {
     //if(Input::old('tanggal')!="" and Input::old('nis')!="") {
     $siswa = \DB::table('t_siswa_tingkat')->where('nis', Input::old('nis'))->first();
     if ($siswa == null) {
         \Session::flash('siswa_ilang', 'NIS tidak ditemukan');
         return redirect('/home');
     }
     $date = Date::createFromFormat('Y-m-d', Input::old('tanggal'));
     $tapel = AbsencesController::checkPeriode($date);
     $tapel['kd_tapel'] = \DB::table('t_tahun_ajaran')->where('tahun_ajaran', $tapel['tahun_ajaran'])->first()->kd_tahun_ajaran;
     $siswa_tingkat = \DB::table('t_siswa_tingkat')->where('nis', $siswa->nis)->where('kd_tahun_ajaran', $tapel['kd_tapel'])->where('kd_periode_belajar', $tapel['periode'])->first();
     if ($siswa_tingkat == null) {
         \Session::flash('tahun_ajaran', 'Tahun ajaran belum dimulai');
         return redirect('/home');
     }
     $siswa = \DB::table('t_siswa')->where('nis', $siswa->nis)->first();
     $pikets = \DB::table('t_piket')->where('hari', $date->format('l'))->first();
     $piket = \DB::table('t_guru')->where('kd_guru', $pikets->kd_guru)->first();
     $jam_masuk = Date::createFromFormat('H:i:s', $pikets->jam_masuk, Date::now()->tzName);
     return view('absences.insert', compact('date', 'jam_masuk', 'siswa', 'siswa_tingkat', 'piket', 'tapel'));
     //}
     //else
     //    return redirect('home');
 }
开发者ID:rizkidoank,项目名称:smansa-absensi,代码行数:25,代码来源:AbsencesController.php

示例4: today

function today()
{
    global $today;
    if (!isset($today)) {
        $today = Date::now();
        $today->hour = 0;
        $today->minute = 0;
        $today->second = 0;
    }
    return $today;
}
开发者ID:ankhzet,项目名称:Ankh,代码行数:11,代码来源:view.php

示例5: getIndex

 public function getIndex()
 {
     $absens = \DB::table('t_kesiangan')->get();
     $kelas = \DB::table('t_siswa_tingkat')->distinct('kd_rombel')->orderBy('kd_rombel')->get(['kd_rombel']);
     $headers = ['NIS', 'Nama', 'Kelas', 'Tahun Ajaran', 'Semester', 'Hari', 'Tanggal', 'Jam Datang', 'Menit Kesiangan', 'Piket', 'Keterangan'];
     $date = Date::now();
     $th1 = strval($date->year - 1) . "/" . strval($date->year);
     $th2 = strval($date->year) . "/" . strval($date->year + 1);
     $t1 = \DB::table('t_tahun_ajaran')->where('tahun_ajaran', $th1)->get();
     $t2 = \DB::table('t_tahun_ajaran')->where('tahun_ajaran', $th2)->get();
     $tahun_ajaran = (object) array_merge((array) $t1, (array) $t2);
     return view('laporan.index', compact('headers', 'absens', 'tahun_ajaran', 'kelas'));
 }
开发者ID:rizkidoank,项目名称:smansa-absensi,代码行数:13,代码来源:LaporanController.php

示例6: showIndex

 /**
  * Returns the rendered Blade templates.
  *
  * @return \Illuminate\View\View
  */
 public function showIndex()
 {
     $today = Date::now();
     $startDate = Date::now();
     segment_page('Status Page');
     // Check if we have another starting date
     if (Binput::has('start_date')) {
         try {
             // If date provided is valid
             $oldDate = Date::createFromFormat('Y-m-d', Binput::get('start_date'));
             segment_track('Status Page', ['start_date' => $oldDate->format('Y-m-d')]);
             // If trying to get a future date fallback to today
             if ($today->gt($oldDate)) {
                 $startDate = $oldDate;
             }
         } catch (Exception $e) {
             // Fallback to today
         }
     }
     $metrics = null;
     if ($displayMetrics = Setting::get('display_graphs')) {
         $metrics = Metric::where('display_chart', 1)->get();
     }
     $daysToShow = Setting::get('app_incident_days') ?: 7;
     $incidentDays = range(0, $daysToShow - 1);
     $dateTimeZone = Setting::get('app_timezone');
     $incidentVisiblity = Auth::check() ? 0 : 1;
     $allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisiblity)->whereBetween('created_at', [$startDate->copy()->subDays($daysToShow)->format('Y-m-d') . ' 00:00:00', $startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) use($dateTimeZone) {
         return (new Date($incident->created_at))->setTimezone($dateTimeZone)->toDateString();
     });
     // Add in days that have no incidents
     foreach ($incidentDays as $i) {
         $date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i);
         if (!isset($allIncidents[$date->toDateString()])) {
             $allIncidents[$date->toDateString()] = [];
         }
     }
     // Sort the array so it takes into account the added days
     $allIncidents = $allIncidents->sortBy(function ($value, $key) {
         return strtotime($key);
     }, SORT_REGULAR, true)->all();
     // Scheduled maintenance code.
     $scheduledMaintenance = Incident::scheduled()->orderBy('scheduled_at')->get();
     // Component & Component Group lists.
     $usedComponentGroups = Component::where('group_id', '>', 0)->groupBy('group_id')->lists('group_id');
     $componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get();
     $ungroupedComponents = Component::where('group_id', 0)->orderBy('order')->orderBy('created_at')->get();
     $canPageBackward = Incident::notScheduled()->where('created_at', '<', $startDate->format('Y-m-d'))->count() != 0;
     return View::make('index', ['componentGroups' => $componentGroups, 'ungroupedComponents' => $ungroupedComponents, 'displayMetrics' => $displayMetrics, 'metrics' => $metrics, 'allIncidents' => $allIncidents, 'scheduledMaintenance' => $scheduledMaintenance, 'aboutApp' => Markdown::convertToHtml(Setting::get('app_about')), 'canPageForward' => (bool) $today->gt($startDate), 'canPageBackward' => $canPageBackward, 'previousDate' => $startDate->copy()->subDays($daysToShow)->toDateString(), 'nextDate' => $startDate->copy()->addDays($daysToShow)->toDateString(), 'pageTitle' => Setting::get('app_name') . ' Status']);
 }
开发者ID:2bj,项目名称:Cachet,代码行数:55,代码来源:HomeController.php

示例7: check

 /**
  * Check if access is allowed given an RFID card identifier.
  *
  * @param   Resource  $resource
  * @param   string    $cardId
  * @return  Response
  */
 public function check(Resource $resource, $cardId)
 {
     $now = Date::now();
     try {
         $card = Card::findOrFail($cardId);
         // @todo: refactor for single responsibility
         $reservation = $resource->reservations()->where('starts_at', '<=', $now)->where('ends_at', '>', $now)->where('user_id', '=', $card->user->id)->first();
         $allow = $reservation ? true : false;
         //
     } catch (ModelNotFoundException $e) {
         $reservation = null;
         $allow = false;
     }
     return ['time' => $now->format('Y-m-d H:i:s'), 'reservation' => $reservation, 'allow' => $allow];
 }
开发者ID:AssociazionePrometeo,项目名称:doorkeeper-web,代码行数:22,代码来源:ResourceController.php

示例8: showIndex

 /**
  * Displays the explore page.
  *
  * @return \Illuminate\View\View
  */
 public function showIndex()
 {
     $today = Date::now();
     $startDate = Date::now();
     // Check if we have another starting date
     if (Binput::has('start_date')) {
         try {
             // If date provided is valid
             $oldDate = Date::createFromFormat('Y-m-d', Binput::get('start_date'));
             // If trying to get a future date fallback to today
             if ($today->gt($oldDate)) {
                 $startDate = $oldDate;
             }
         } catch (Exception $e) {
             // Fallback to today
         }
     }
     $daysToShow = Setting::get('app_issue_days', 0) - 1;
     if ($daysToShow < 0) {
         $daysToShow = 0;
         $issueDays = [];
     } else {
         $issueDays = range(0, $daysToShow);
     }
     $dateTimeZone = Setting::get('app_timezone');
     $issueVisiblity = Auth::check() ? 0 : 1;
     $allIssues = Issue::where('visible', '>=', $issueVisiblity)->whereBetween('created_at', [$startDate->copy()->subDays($daysToShow)->format('Y-m-d') . ' 00:00:00', $startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get()->groupBy(function (Issue $issue) use($dateTimeZone) {
         // If it's scheduled, get the scheduled at date.
         if ($issue->is_scheduled) {
             return (new Date($issue->scheduled_at))->setTimezone($dateTimeZone)->toDateString();
         }
         return (new Date($issue->created_at))->setTimezone($dateTimeZone)->toDateString();
     });
     // Add in days that have no issues
     foreach ($issueDays as $i) {
         $date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i);
         if (!isset($allIssues[$date->toDateString()])) {
             $allIssues[$date->toDateString()] = [];
         }
     }
     // Sort the array so it takes into account the added days
     $allIssues = $allIssues->sortBy(function ($value, $key) {
         return strtotime($key);
     }, SORT_REGULAR, true)->all();
     return View::make('index')->withDaysToShow($daysToShow)->withAllIssues($allIssues)->withCanPageForward((bool) $today->gt($startDate))->withCanPageBackward(Issue::where('created_at', '<', $startDate->format('Y-m-d'))->count() > 0)->withPreviousDate($startDate->copy()->subDays($daysToShow)->toDateString())->withNextDate($startDate->copy()->addDays($daysToShow)->toDateString());
 }
开发者ID:emtudo,项目名称:Gitamin,代码行数:51,代码来源:ExploreController.php

示例9: indexAction

 /**
  * Displays the explore page.
  *
  * @return \Illuminate\View\View
  */
 public function indexAction()
 {
     $this->subMenu['explore']['active'] = true;
     $today = Date::now();
     $startDate = Date::now();
     // Check if we have another starting date
     if (Request::has('start_date')) {
         try {
             // If date provided is valid
             $oldDate = Date::createFromFormat('Y-m-d', Request::get('start_date'));
             // If trying to get a future date fallback to today
             if ($today->gt($oldDate)) {
                 $startDate = $oldDate;
             }
         } catch (Exception $e) {
             // Fallback to today
         }
     }
     $daysToShow = Setting::get('app_issue_days', 0) - 1;
     if ($daysToShow < 0) {
         $daysToShow = 0;
         $issueDays = [];
     } else {
         $issueDays = range(0, $daysToShow);
     }
     $dateTimeZone = Setting::get('app_timezone');
     $allIssues = Issue::whereBetween('created_at', [$startDate->copy()->subDays($daysToShow)->format('Y-m-d') . ' 00:00:00', $startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('created_at', 'desc')->get()->groupBy(function (Issue $issue) use($dateTimeZone) {
         return (new Date($issue->created_at))->setTimezone($dateTimeZone)->toDateString();
     });
     // Add in days that have no issues
     foreach ($issueDays as $i) {
         $date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i);
         if (!isset($allIssues[$date->toDateString()])) {
             $allIssues[$date->toDateString()] = [];
         }
     }
     // Sort the array so it takes into account the added days
     $allIssues = $allIssues->sortBy(function ($value, $key) {
         return strtotime($key);
     }, SORT_REGULAR, true)->all();
     return View::make('explore.index')->withPageTitle(trans('dashboard.explore'))->withProjects([])->withSubMenu($this->subMenu)->withDaysToShow($daysToShow)->withAllIssues($allIssues)->withCanPageForward((bool) $today->gt($startDate))->withCanPageBackward(Issue::where('created_at', '<', $startDate->format('Y-m-d'))->count() > 0)->withPreviousDate($startDate->copy()->subDays($daysToShow)->toDateString())->withNextDate($startDate->copy()->addDays($daysToShow)->toDateString());
 }
开发者ID:xiaobailc,项目名称:Gitamin,代码行数:47,代码来源:ExploreController.php

示例10: onFlush

 /**
  * @param OnFlushEventArgs $args
  */
 public function onFlush(OnFlushEventArgs $args)
 {
     $entityManager = $args->getEntityManager();
     $unitOfWork = $entityManager->getUnitOfWork();
     foreach ($unitOfWork->getScheduledEntityDeletions() as $entity) {
         if (!$this->isSoftDeletable($entity)) {
             continue;
         }
         $metadata = $entityManager->getClassMetadata(get_class($entity));
         $oldValue = $metadata->getFieldValue($entity, $this->propertyName);
         if ($oldValue !== null) {
             continue;
         }
         $newValue = Date::now();
         $metadata->setFieldValue($entity, $this->propertyName, $newValue);
         $entityManager->persist($entity);
         $unitOfWork->propertyChanged($entity, $this->propertyName, $oldValue, $newValue);
         $unitOfWork->scheduleExtraUpdate($entity, [$this->propertyName => [$oldValue, $newValue]]);
     }
 }
开发者ID:simonbowen,项目名称:lumen-doctrine,代码行数:23,代码来源:SoftDeletesListener.php

示例11: createOrUpdateFixtures

 /**
  * @return string
  */
 public function createOrUpdateFixtures()
 {
     $dateOfBeginningMonth = Date::now()->startOfMonth()->format('d.m.Y');
     $dateOfEndingMonth = Date::now()->endOfMonth()->format('d.m.Y');
     $request = 'matches?comp_id=' . $this->premierleague . ',' . $this->ucl . ',' . $this->europa . ',' . $this->facup . '&team_id=' . $this->liverpoolfc . '&from_date=' . $dateOfBeginningMonth . '&to_date=' . $dateOfEndingMonth . '&';
     $getMatches = $this->connector($request);
     foreach ($getMatches as $match) {
         $match['match_id'] = $match['id'];
         unset($match['id']);
         $mergeDateTime = Date::createFromFormat('d.m.Y H:i', $match['formatted_date'] . ' ' . $match['time'], 'UTC')->tz('Asia/Bangkok')->toDateTimeString();
         $date = Date::createFromFormat('Y-m-d H:i:s', $mergeDateTime)->format('Y-m-d');
         $match['formatted_date'] = $date;
         $time = Date::createFromFormat('Y-m-d H:i:s', $mergeDateTime)->format('H:i');
         $matchStatus = $match['status'];
         $match['status'] === $match['time'] ? $match['status'] = $time : ($match['status'] = $matchStatus);
         $match['time'] = $time;
         if ($match['localteam_score'] === '?' and $match['visitorteam_score'] === '?' or $match['localteam_score'] === '' and $match['visitorteam_score'] === '') {
             if ($match['status'] !== 'FT' or $match['status'] !== 'AET') {
                 $match['localteam_score'] = '-';
                 $match['visitorteam_score'] = '-';
             }
         }
         $this->footballMatches->updateOrCreate(['match_id' => $match['match_id']], $match);
         if (!empty($match['events'])) {
             $events = $match['events'];
             $matchId = $match['match_id'];
             foreach ($events as $event) {
                 $event['match_id'] = $matchId;
                 $event['event_id'] = $event['id'];
                 unset($event['id']);
                 $this->footballMatchEvents->updateOrCreate(['event_id' => $event['event_id']], $event) ? Log::info('Event of ' . $matchId . ' update completed!.') : Log::error('Event update process of ' . $matchId . ' failed');
             }
         }
         Log::info('All data of ' . $match['match_id'] . ' update completed!');
     }
     return Event::fire(new FootballMatchUpdated($this->footballMatches));
 }
开发者ID:boynoiz,项目名称:liverpoolthailand,代码行数:40,代码来源:FootballController.php

示例12: testAgoTranslated

 public function testAgoTranslated()
 {
     Date::setLocale('nl');
     $date = Date::parse('-5 years');
     $this->assertSame("5 jaar geleden", $date->ago());
     $date = Date::parse('-5 months');
     $this->assertSame("5 maanden geleden", $date->ago());
     $date = Date::parse('-32 days');
     $this->assertSame("1 maand geleden", $date->ago());
     $date = Date::parse('-4 days');
     $this->assertSame("4 dagen geleden", $date->ago());
     $date = Date::parse('-1 day');
     $this->assertSame("1 dag geleden", $date->ago());
     $date = Date::parse('-3 hours');
     $this->assertSame("3 uur geleden", $date->ago());
     $date = Date::parse('-1 hour');
     $this->assertSame("1 uur geleden", $date->ago());
     $date = Date::parse('-2 minutes');
     $this->assertSame("2 minuten geleden", $date->ago());
     $date = Date::parse('-1 minute');
     $this->assertSame("1 minuut geleden", $date->ago());
     $date = Date::parse('-50 second');
     $this->assertSame("50 seconden geleden", $date->ago());
     $date = Date::parse('-1 second');
     $this->assertSame("1 seconde geleden", $date->ago());
     $date = Date::parse('+5 days');
     $this->assertSame("5 dagen vanaf nu", $date->ago());
     $date = Date::parse('+5 days');
     $this->assertSame("5 dagen na", $date->ago(Date::now()));
     $date = Date::parse('-5 days');
     $this->assertSame("5 dagen voor", $date->ago(Date::now()));
     Date::setLocale('ru');
     $date = Date::parse('-21 hours');
     $this->assertSame("21 час до", $date->ago(Date::now()));
     $date = Date::parse('-11 hours');
     $this->assertSame("11 часов до", $date->ago(Date::now()));
 }
开发者ID:erpio,项目名称:Reportula,代码行数:37,代码来源:DateTest.php

示例13: scopeActive

 public function scopeActive($query)
 {
     return $query->where('ends_at', '>=', Date::now());
 }
开发者ID:AssociazionePrometeo,项目名称:doorkeeper-web,代码行数:4,代码来源:Reservation.php

示例14: CsvExporter

<?php

require 'vendor/autoload.php';
use Acme\CsvExporter;
use Acme\DataGenerator;
use Jenssegers\Date\Date;
$start = Date::now()->firstOfMonth();
$csvExporter = new CsvExporter('salaryDates.csv');
$dataGenerator = new DataGenerator($start);
$data = $dataGenerator->generate();
$csvExporter->export($data);
开发者ID:bart,项目名称:salary,代码行数:11,代码来源:index.php

示例15: makeTimelineData

 private function makeTimelineData($timeline)
 {
     Carbon::setLocale('pt_BR');
     foreach ($timeline as $key => $item) {
         $now = Carbon::now();
         $start = Carbon::createFromFormat('Y-m-d H:i:s', $item['start']);
         $end = Carbon::createFromFormat('Y-m-d H:i:s', $item['end']);
         $startW3c = Carbon::createFromFormat('Y-m-d H:i:s', $item['start'])->addSeconds(env('TIME_OFFSET_ADD'));
         $endW3c = Carbon::createFromFormat('Y-m-d H:i:s', $item['end'])->addSeconds(env('TIME_OFFSET_ADD'));
         $timeline[$key]['startW3c'] = $startW3c->toW3cString();
         $timeline[$key]['endW3c'] = $endW3c->toW3cString();
         $end->addSeconds(2);
         $diff = $start->diffInDays($end);
         if ($diff <= 1) {
             $period = $start->format('d \\d\\e F');
         } else {
             if ($start->month == $end->month) {
                 $period = $start->format('d') . ' a ' . $end->format('d \\d\\e F');
             } else {
                 $period = $start->format('d \\d\\e F') . ' a ' . $end->format('d \\d\\e F');
             }
         }
         $timeline[$key]['period'] = $period;
         $timeline[$key]['past'] = $start->diffInSeconds($now) > 0;
     }
     return ['lines' => $timeline, 'now' => $now->toW3cString()];
 }
开发者ID:alerj,项目名称:parlamentojuvenil,代码行数:27,代码来源:Data.php


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