本文整理汇总了PHP中Jenssegers\Date\Date::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::parse方法的具体用法?PHP Date::parse怎么用?PHP Date::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jenssegers\Date\Date
的用法示例。
在下文中一共展示了Date::parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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];
}
示例2: testCustomSuffix
public function testCustomSuffix()
{
Date::setLocale('de');
$date = Date::parse('-1 month');
$this->assertSame("vor 1 Monat", $date->ago());
$date = Date::parse('-5 months');
$this->assertSame("vor 5 Monaten", $date->ago());
$date = Date::parse('-5 seconds');
$this->assertSame("vor 5 Sekunden", $date->ago());
}
示例3: renderHtml
public function renderHtml()
{
if ($this->_response) {
$data = [];
foreach ($this->_response as $tweet) {
$data[] = ['userImage' => $tweet->user->profile_image_url, 'userName' => $tweet->user->name, 'created' => Date::parse($tweet->created_at)->ago(), 'text' => StrHelper::removeEmoji($tweet->text), 'source' => $tweet->source];
}
return Application::getInstance()->jadeEngine()->render(Application::getInstance()->getBasePath() . '/frontend/src/jade/resource/twitter.jade', ['data' => $data]);
}
}
示例4: reloadQuestions
private function reloadQuestions($id)
{
$questions = Question::where('product_id', $id)->orderBy('created_at', 'DESC')->get();
foreach ($questions as $question) {
$question['texts'] = Text::with('user')->where('question_id', $question->id)->get();
foreach ($question->texts as $text) {
$text['date'] = Date::parse($text->created_at)->diffForHumans();
}
}
return $questions;
}
示例5: getUpdatedAtAttribute
/**
* Create an instance of a Date object, when retrieving the updated_at attribute.
* Set its locale.
*
* @param $value
* @return Date
*/
protected function getUpdatedAtAttribute($value)
{
$date = $this['updated_at'] = Date::parse($value);
$date->setLocale(LaravelLocalization::getCurrentLocale());
$locale = LaravelLocalization::getCurrentLocale();
if ($locale == 'de') {
return $date->format('j. F, Y');
} else {
return $date->format('jS F, Y');
}
}
示例6: testDates
public function testDates() {
$dates = [
'3 Nov 2015',
'11/03/2015',
'2015-11-03',
'Tue, 03 Nov 2015 13:40:06 +0300'
];
$needle = '3 ноября 2015';
foreach ($dates as $date) {
$this->assertEquals($needle, Date::parse($date)->format('j F Y'));
}
}
示例7: createClassrooms
private function createClassrooms($interval)
{
$classrooms = $interval->classrooms;
$WiziqApi = new WiziqApi();
if (App::environment() == 'local') {
$status_ping_url = 'http://46.40.236.186:9090/DARES/public/classrooms/classrooms/status_ping';
// $status_ping_url = 'https://el-css.edu.om/admin/public/classrooms/classrooms/status_ping';
} else {
$status_ping_url = 'https://google.com';
// $status_ping_url = 'https://el-css.edu.om/admin/public/classrooms/classrooms/status_ping';
}
// Log::info($status_ping_url);
foreach ($classrooms as $classroom) {
$error = 0;
$subject = $classroom->subject;
$teacher = $classroom->teacher;
$increment_date = Date::parse($interval->from_date . " " . $classroom->hour);
while ($increment_date->format("Y-m-d H:i:s") <= $interval->to_date . " 23:59:59") {
$exists = ClassroomSession::where('start_at', $increment_date->format("Y-m-d H:i:s"))->where('classroom_id', $classroom->id)->count();
if ($increment_date->dayOfWeek == $classroom->day && $increment_date->isFuture() && !$exists) {
try {
$wiziqclassroom = WiziqClassroom::build($interval->title . " - " . $subject->name, new DateTime($increment_date->format("Y-m-d H:i:s")))->withPresenter($teacher->id, $teacher->name)->withAttendeeLimit(config("classrooms.attendee_limit"))->withReturnUrl('')->withDuration(60)->withExtendDuration(0)->withStatusPingUrl($status_ping_url)->withTimeZone("Asia/Muscat")->withLanguageCultureName("ar-SA")->withCreateRecording(true);
$response = $WiziqApi->create($wiziqclassroom);
$data = ['title' => $interval->title, 'wiziq_id' => $response['class_id'], 'interval_id' => $interval->id, 'classroom_id' => $classroom->id, 'subject_subject_id' => $subject->id, 'teacher_id' => $teacher->id, 'start_at' => $increment_date->format("Y-m-d H:i:s"), 'duration' => 60, 'recording_link' => $response['recording_url'], 'presenter_link' => $response['presenter_url']];
/** add attendees to virtual classroom */
if ($session = ClassroomSession::create($data)) {
$error = $this->createStudentsSessions($classroom->students, $session);
}
//\Log::info($response);
} catch (\mikemix\Wiziq\Common\Api\Exception\CallException $e) {
// \Log::warning($e->getMessage());
$error = 1;
} catch (\mikemix\Wiziq\Common\Http\Exception\InvalidResponseException $e) {
// \Log::warning($e->getMessage());
$error = 1;
} catch (\PDOException $e) {
$error = 1;
}
}
$increment_date->add("1 day");
}
if ($error == 0) {
$interval->state = 'done';
$interval->save();
event(new IntervalVirtualClassroomsCreated($interval->title));
}
}
}
示例8: getIndex
/**
* Show the homepage
* @return \View
*/
public function getIndex()
{
if (Request::isMethod('post')) {
$addition = [];
if (\Auth::check()) {
$addition = ['check_liked' => ['user_id' => \Auth::user()->id]];
}
$posts = $this->post->index(10, null, null, null, 'created_at', 'desc', $addition);
$tmp = [];
foreach ($posts as $post) {
$tmp[] = ['id' => $post->id, 'title' => $post->title, 'slug' => $post->slug, 'code' => $post->code, 'url' => $post->getLink(), 'thumbnail' => \Timthumb::link($post->getThumbnail(), 500), 'username' => $post->username, 'user_id' => $post->user_id, 'type' => $post->type, 'name' => $post->name, 'views' => $post->views, 'likes' => $post->likes, 'score' => $post->score, 'comments' => 0, 'created_at_string' => Date::parse($post->created_at)->diffForHumans()];
}
$response = ['status' => '1', 'msg' => 'success', 'data' => $tmp];
return $this->json($response);
} else {
return $this->view('gag.frontend.homes.index');
}
}
示例9: _getFromArticle
private function _getFromArticle(Article $article)
{
$img = StrHelper::getImgSrcFromHtml($article->description);
return ['link' => $article->link, 'pubDate' => Date::parse($article->pubDate)->ago(), 'title' => $article->title, 'description' => StrHelper::wordWrap($article->description), 'img' => $img];
}
示例10: getCreatedAttribute
/**
* Get the created date
*
* @return string
*/
public function getCreatedAttribute()
{
return Date::parse($this->created_at)->format('d-m-Y');
}
示例11: getHourAttribute
/**
* mutators
*/
public function getHourAttribute($value)
{
return Date::parse($value)->format("H:i");
}
示例12: getCreatedAtAttribute
public function getCreatedAtAttribute()
{
return Date::parse($this->attributes['created_at']);
}
示例13:
<div class="text-center bigtext1 alert alert-warning alert-important">
Tem certeza que deseja excluir o evento <span class="destaque">"{{$evento->titulo}}"</span>?
</div>
<hr/>
<div class="row text-center">
<div class="col-md-2 text-right destaque">Título do Evento:</div>
<div class="col-md-8 text-left">{{$evento->titulo}}</div>
</div>
<div class="row text-center">
<div class="col-md-2 text-right destaque">Data do Evento:</div>
<div class="col-md-8 text-left">
<?php
echo Date::parse($evento->hora)->format('l, j \\d\\e F \\d\\e Y \\à\\s H\\hi');
?>
({{ $evento->hora->diffForHumans()}})
</div>
</div>
<div class="row text-center">
<div class="col-md-2 text-right destaque">Criado por:</div>
<div class="col-md-8 text-left">{{$evento->createBy->name}}</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="btn-group">
{{ Form::model($evento, ['method' => 'DELETE' , 'route'=>['musica.evento.destroy',$evento->id],
示例14: getData
/**
* Return model in Datatable ajax | Also search by ajax.
*
* @return mixed
*/
public function getData()
{
$model = $this->crud['model'];
$columns = $this->crud['columns'];
//Check if has a pivot column
$pivots = array_pluck($this->crud['columns'], ['pivot']);
$isPivot = array_search('true', $pivots);
if ($isPivot != false) {
$pivotField = $this->crud['columns'][$isPivot];
// dd($pivotField);
$data = $model::select('*')->get();
//dd($columns);
} else {
$data = $model::select('*')->get();
}
$datatable = Datatables::of($data);
foreach ($columns as $column) {
if (isset($column['type']) && $column['type'] == 'select_multiple') {
$datatable->addColumn($column['name'], '')->editColumn($column['name'], function ($columnInfo) use($column) {
$results = $columnInfo->{$column['entity']}()->getResults();
$html = '-';
if ($results && $results->count()) {
$results_array = $results->lists($column['attribute'], 'id');
$html = implode(', ', $results_array->toArray());
}
return $html;
});
} elseif (isset($column['type']) && $column['type'] == 'select') {
$datatable->addColumn($column['name'], '')->editColumn($column['name'], function ($columnInfo) use($column) {
$html = '-';
if ($columnInfo->{$column['entity']}()->getResults()) {
$html = $columnInfo->{$column['entity']}()->getResults()->{$column['attribute']};
}
return $html;
});
} elseif (isset($column['type']) && $column['type'] == 'model_function') {
$datatable->addColumn($column['name'], '')->editColumn($column['name'], function ($columnInfo) use($column) {
return $columnInfo->{$column['function_name']}();
});
} elseif (isset($column['type']) && $column['type'] == 'image') {
$datatable->addColumn($column['name'], '')->editColumn($column['name'], function ($columnInfo) use($column) {
return "<img src='" . asset($columnInfo->{$column['name']}) . "' width='50%' />";
});
} elseif (isset($column['type']) && $column['type'] == 'browse') {
$datatable->addColumn($column['name'], '')->editColumn($column['name'], function ($columnInfo) use($column) {
if (isset($column['browse']) && $column['browse'] != 'image') {
return $columnInfo->content;
}
return "<img src='" . asset($columnInfo->{$column['name']}) . "' width='50%' />";
});
} elseif (isset($column['type']) && isset($column['pivot']) && $column['pivot'] == true) {
$datatable->editColumn($column['name'], function ($columnInfo) use($column) {
// dd($columnInfo);
// dd($column); //["model"]
$pivotModel = $this->crud['model'];
$dataPivot = $column['model']::find($columnInfo[$column['entity']]);
if ($dataPivot) {
return $dataPivot->{$column}['attribute'];
}
});
} elseif (isset($column['type']) && $column['type'] == 'date') {
$datatable->addColumn($column['name'], '')->editColumn($column['name'], function ($columnInfo) use($column) {
if ($columnInfo->{$column['name']} != null) {
$locale = isset($column['language']) ? $column['language'] : 'en';
$format = isset($column['format']) ? $column['format'] : 'Y-m-d';
Date::setLocale($locale);
$date = Date::parse($columnInfo->{$column['name']});
return $date->format($format);
}
return '';
});
} else {
if (array_search('content', $columns)) {
$datatable->editColumn($column['name'], function ($columnInfo) use($column) {
return strip_tags(Str::words($columnInfo->content, 50, '...'));
});
} else {
$datatable->editColumn($column['name'], function ($columnInfo) use($column) {
if (trim($columnInfo->{$column['name']}) == '') {
if (isset($this->crud['is_translate']) && $this->crud['is_translate'] == true) {
if ($columnInfo->translate()) {
$columnInfo->{$column['name']} = $columnInfo->{$column['name']};
}
}
}
return str_limit(strip_tags($columnInfo->{$column['name']}), 80, '[...]');
});
}
}
}
if (!(isset($crud['edit_permission']) && $crud['edit_permission'] === false && isset($crud['delete_permission']) && $crud['delete_permission'] === false)) {
$datatable->addColumn('actions', '')->editColumn('actions', function ($column) {
$html = '';
if (!(isset($crud['edit_permission']) && !$crud['edit_permission'])) {
$html .= '<a href="' . url($this->crud['route']) . '/' . $column->id . '/edit" class="btn btn-xs btn-complete "><i class="fa fa-edit p-r-10"></i>' . _(trans('crud.edit')) . '</a>';
//.........这里部分代码省略.........
示例15: 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()));
}