本文整理汇总了PHP中Jenssegers\Date\Date类的典型用法代码示例。如果您正苦于以下问题:PHP Date类的具体用法?PHP Date怎么用?PHP Date使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Date类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: home
/**
* Display a listing of the resource.
*
* @return Response
*/
public function home()
{
$lastNews = News::orderBy('id', 'desc')->first();
$lastNews->description = $this::text_humanized($lastNews->description);
Date::setLocale('fr');
$date = new Date($lastNews->when);
$lastNews->when = $date->format('l j F Y');
$lastNews->hour = $date->format('H:i');
return view('page/home', ['news' => $lastNews]);
}
示例2: build
public function build()
{
$translator = $this->processor->getTranslator();
$html = "";
Date::setLocale($this->locale);
if ($this->printStyles) {
$html .= $this->getStylesHtml();
}
$hidden = $this->isModal ? ' style="display:none;"' : '';
if ($this->printFrame) {
$html .= '<div id="changemodal-wrapper"' . $hidden . '><div id="changemodal"' . $hidden . '><div id="changemodal-frame"><h1>' . $this->title . '</h1>';
if ($this->isModal) {
$html .= '<i id="close-button" class="fa fa-times"></i>';
}
} else {
$html .= '<div id="changemodal">';
}
$html .= '<div class="changelog">';
try {
foreach ($this->processor->getVersions() as $version) {
$html .= '<h2 id="' . $version->getVersion() . '"';
if ($version->isYanked()) {
$html .= ' class="yanked" title="' . $translator->translateTo('This release has been yanked.') . '"';
}
$html .= '>' . $version->getVersion() . '</h2>';
if ($version->isReleased() && $version->getReleaseDate() !== null) {
$date = new Date($version->getReleaseDate()->getTimestamp());
$html .= '<h3 title="' . '">' . $date->ago();
if ($this->printDownloadLinks && !$version->isYanked()) {
$html .= ' <a href="' . $version->getUrl() . '" target="_blank"><i class="fa fa-download"></i></a>';
}
$html .= '</h3>';
}
$html .= '<div class="version-wrapper">';
foreach ($version->getChanges() as $label => $changes) {
$html .= '<ul class="' . $label . '">';
foreach ($changes as $change) {
$html .= '<li data-label="' . ucfirst($translator->translateTo($label)) . '">' . $change . '</li>';
}
$html .= '</ul>';
}
$html .= '</div>';
}
} catch (\Exception $e) {
$html .= '<div class="alert alert-danger" style="text-align: center" role="alert">' . '<i class="fa fa-lg fa-exclamation-triangle"></i><br>' . '<b>Could not get Changelog!</b><br>' . 'Error: <em>' . $e->getMessage() . '</em>' . '</div>';
}
$html .= '</div></div>';
if ($this->printFrame) {
$html .= '</div>';
}
if ($this->printScripts) {
$html .= $this->getScriptsHtml();
}
return $html;
}
示例3: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$categories = ForumCategories::all();
$categorie = ForumCategories::where('slug', $id)->first();
foreach ($categorie->subjects as $subject) {
Date::setLocale('fr');
$date = new Date($subject->created);
$subject->when = $date->format('j F Y');
}
return view('forum.categorie.show', ['categorie' => $categorie]);
}
示例4: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$sujet = ForumSubjects::where("id", $id)->first();
$categorie = ForumCategories::find($sujet->category);
foreach ($sujet->messages as $message) {
Date::setLocale('fr');
$date = new Date($message->created);
$message->when = $date->format('j F Y');
$message->message = $this::text_humanized($message->message);
$message->message = BBCode::parse($message->message);
}
return view('forum.sujets.show', ['categorie' => $categorie, "sujet" => $sujet]);
}
示例5: testConvert
/**
* @covers ::convert
*/
public function testConvert()
{
$test1 = Converter::convert(Calends::create(0, 'unix'));
$this->assertEquals(['start' => Date::createFromTimestamp(0), 'duration' => \Carbon\CarbonInterval::seconds(0), 'end' => Date::createFromTimestamp(0)], $test1);
$test2 = Converter::convert(Calends::create(['start' => 0, 'end' => 86400], 'unix'));
$this->assertEquals(['start' => Date::createFromTimestamp(0), 'duration' => \Carbon\CarbonInterval::seconds(86400), 'end' => Date::createFromTimestamp(86400)], $test2);
}
示例6: testTranslatesDays
public function testTranslatesDays()
{
$days = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday');
foreach ($this->languages as $language) {
$translations = (include "src/lang/{$language}/date.php");
foreach ($days as $day) {
$date = new Date($day);
$date->setLocale($language);
$this->assertTrue(isset($translations[$day]));
$this->assertEquals($translations[$day], $date->format('l'), "Language: {$language}");
// Full
$this->assertEquals(substr($translations[$day], 0, 3), $date->format('D'), "Language: {$language}");
// Short
}
}
}
示例7: handle
/**
* Handle the report incident command.
*
* @param \CachetHQ\Cachet\Commands\Incident\ReportIncidentCommand $command
*
* @return \CachetHQ\Cachet\Models\Incident
*/
public function handle(ReportIncidentCommand $command)
{
$data = ['name' => $command->name, 'status' => $command->status, 'message' => $command->message, 'visible' => $command->visible];
// Link with the component.
if ($command->component_id) {
$data['component_id'] = $command->component_id;
}
// The incident occurred at a different time.
if ($command->incident_date) {
$incidentDate = Date::createFromFormat('d/m/Y H:i', $command->incident_date, config('cachet.timezone'))->setTimezone(Config::get('app.timezone'));
$data['created_at'] = $incidentDate;
$data['updated_at'] = $incidentDate;
}
// Create the incident
$incident = Incident::create($data);
// Update the component.
if ($command->component_id) {
Component::find($command->component_id)->update(['status' => $command->component_status]);
}
// Notify subscribers.
if ($command->notify) {
event(new IncidentWasReportedEvent($incident));
}
return $incident;
}
示例8: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
Date::setLocale('th');
$user = Auth::user();
$jobapps = Jobapp::all();
return view('hr.jobapps.index', compact('jobapps', 'user'));
}
示例9: 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');
}
示例10: 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'));
}
示例11: convertToPHPValue
public function convertToPHPValue($value, AbstractPlatform $platform)
{
$result = parent::convertToPHPValue($value, $platform);
if ($result instanceof \DateTime) {
return Date::instance($result);
}
return $result;
}
示例12: handle
/**
* Handle the report maintenance command.
*
* @param \CachetHQ\Cachet\Commands\Incident\ReportMaintenanceCommand $command
*
* @return \CachetHQ\Cachet\Models\Incident
*/
public function handle(ReportMaintenanceCommand $command)
{
$scheduledAt = Date::createFromFormat('d/m/Y H:i', $command->timestamp, config('cachet.timezone'))->setTimezone(Config::get('app.timezone'));
$maintenanceEvent = Incident::create(['name' => $command->name, 'message' => $command->message, 'scheduled_at' => $scheduledAt, 'status' => 0, 'visible' => 1]);
// Notify subscribers.
event(new MaintenanceWasScheduledEvent($maintenanceEvent));
return $maintenanceEvent;
}
示例13: showText
private function showText($request)
{
$texts = Text::with('user', 'question')->where('question_id', $request->question_id)->get(['created_at', 'user_id', 'description', 'question_id']);
foreach ($texts as $text) {
$text['date'] = Date::parse($text->created_at)->diffForHumans();
}
return ['text' => $texts];
}
示例14: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$album = Albums::find($id);
$date = new Date('now', 'Europe/Brussels');
$date->month = $album->mois + 1;
$album->mois = $date->format('F');
$proprietaire = User::find($album->ID_proprietaire);
$album->proprietaire_nom = $proprietaire->first_name . ' ' . $proprietaire->last_name . ' (Propriétaire)';
$picturesData = $album->pictures;
$pictures = array();
$i = 0;
foreach ($picturesData as $picture) {
$pictures[$i]['big'] = $picture->directory . '/' . $picture->name;
$pictures[$i]['thumb'] = $picture->directory . '/thumb2_' . $picture->name;
$i++;
}
return view('albums.show', compact('album', 'pictures'));
}
示例15: index
function index(Request $request, $id)
{
if (auth()->user()->role_id == 3) {
$plan = PlanProvider::where('provider_id', auth()->user()->provider->id)->orderBy('created_at', 'DESC')->first();
$finalPlan = new Date();
if ($plan) {
$date = new Date($plan->created_at);
$finalPlan = $date->addMonths($plan->period);
}
if (new Date() >= $finalPlan) {
PlanProvider::create(['provider_id' => auth()->user()->provider->id, 'name' => $request->name, 'description' => $request->description, 'period' => $request->period, 'price' => $request->price]);
return redirect()->route('inactivePlan');
}
return redirect()->route('admin')->with(['message' => "Usted ya ha comprado un plan. Este finaliza el día {$finalPlan}"]);
} else {
return redirect()->route('admin')->with('messageError', 1);
}
}