本文整理汇总了PHP中Carbon\Carbon::isToday方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::isToday方法的具体用法?PHP Carbon::isToday怎么用?PHP Carbon::isToday使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carbon\Carbon
的用法示例。
在下文中一共展示了Carbon::isToday方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFilters
/**
* Dodatkowe filtry Twig zwiazane z formatowaniem danych uzytkownika
*
* @return array
*/
public function getFilters()
{
return [new Twig_SimpleFilter('format_date', function ($dateTime, $diffForHumans = true) {
$format = Auth::check() ? auth()->user()->date_format : '%Y-%m-%d %H:%M';
if (!$dateTime instanceof Carbon) {
$dateTime = new Carbon($dateTime);
}
$now = Carbon::now();
if (!$diffForHumans) {
return $dateTime->formatLocalized($format);
} elseif ($dateTime->diffInHours($now) < 1) {
return $dateTime->diffForHumans(null, true) . ' temu';
} elseif ($dateTime->isToday()) {
return 'dziś, ' . $dateTime->format('H:i');
} elseif ($dateTime->isYesterday()) {
return 'wczoraj, ' . $dateTime->format('H:i');
} else {
return $dateTime->formatLocalized($format);
}
}), new Twig_SimpleFilter('timestamp', function ($dateTime) {
if ($dateTime instanceof Carbon) {
return $dateTime->getTimestamp();
} else {
return strtotime($dateTime);
}
})];
}
示例2: __construct
public function __construct($designation, Carbon $startTime, Carbon $endTime = null, $code = 0, Exception $previous = null)
{
switch ($code) {
case 1:
$startString = $startTime->isToday() ? 'today starting at ' . $startTime->format('g:ia') : $startTime->format('M jS g:ia');
$endString = $endTime->isToday() ? $endTime->format('g:ia') : $endTime->format('M jS g:ia');
$this->message = sprintf($this->messageBetween, $designation, $startString, $endString);
break;
case 2:
$startString = $startTime->isToday() ? $startTime->format('g:ia') : $startTime->format('M jS g:ia');
$this->message = sprintf($this->messageAfter, $designation, $startString);
break;
case 3:
$endString = $endTime->isToday() ? $endTime->format('g:ia') : $endTime->format('M jS g:ia');
$this->message = sprintf($this->messageBefore, $designation, $endString);
break;
}
parent::__construct($this->message, $code, $previous);
}
示例3: formatHistory
public static function formatHistory($val)
{
$time = new Carbon($val);
$now = Carbon::now();
if ($time->isToday() == $now->isToday()) {
return 'Today at ' . $val->format('H:i');
} elseif ($time->isYesterday()) {
return 'Yesterday at ' . $val->format('H:i');
} elseif ($time->format('Y') == $now->format('Y')) {
return $val->format('d M, H:i');
} elseif ($time->format('Y') != $now->format('Y')) {
return $val->format('d M Y, H:i');
}
}
示例4: draw_list
/**
* Make a calendar list of events.
*
* Outputs a list of events according to events for the specified range.
*
* @since 3.0.0
* @access private
*
* @param int $timestamp
* @param int $id
*
* @return string
*/
private function draw_list($timestamp, $id = 0)
{
$calendar = $this->calendar;
if (empty($calendar)) {
$calendar = $this->calendar = simcal_get_calendar(intval($id));
if (!$calendar instanceof Default_Calendar) {
return '';
}
}
date_default_timezone_set($calendar->timezone);
$now = $calendar->now;
$current_events = $this->get_events($timestamp);
$day_format = explode(' ', $calendar->date_format);
ob_start();
// Draw the events.
$block_tag = $calendar->compact_list && !empty($current_events) ? 'div' : 'dl';
$data_heading = '';
$heading = $this->get_heading();
foreach ($heading as $k => $v) {
$data_heading .= ' data-heading-' . $k . '="' . $v . '"';
}
echo '<' . $block_tag . ' class="simcal-events-list-container"' . ' data-prev="' . $this->prev . '"' . ' data-next="' . $this->next . '"' . $data_heading . '>';
if (!empty($current_events) && is_array($current_events)) {
foreach ($current_events as $ymd => $events) {
$day_ts = Carbon::createFromFormat('Ymd', $ymd, $calendar->timezone)->getTimestamp();
if (!$calendar->compact_list) {
$date = new Carbon('now', $calendar->timezone);
$date->setLocale(substr(get_locale(), 0, 2));
$date->setTimestamp($day_ts);
if ($date->isToday()) {
$the_color = new Color($calendar->today_color);
} else {
$the_color = new Color($calendar->days_events_color);
}
$bg_color = '#' . $the_color->getHex();
$color = $the_color->isDark() ? '#ffffff' : '#000000';
$border_style = ' style="border-bottom: 1px solid ' . $bg_color . ';" ';
$bg_style = ' style="background-color: ' . $bg_color . '; color: ' . $color . ';"';
echo "\t" . '<dt class="simcal-day-label"' . $border_style . '>';
echo '<span' . $bg_style . '>';
foreach ($day_format as $format) {
echo $format ? '<span class="simcal-date-format" data-date-format="' . $format . '">' . date_i18n($format, $day_ts) . '</span> ' : ' ';
}
echo '</span>';
echo '</dt>' . "\n";
}
$list_events = '<ul class="simcal-events">' . "\n";
$calendar_classes = array();
$day_classes = 'simcal-weekday-' . date('w', $day_ts);
// Is this the present, the past or the future, Doc?
if ($timestamp <= $now && $timestamp >= $now) {
$day_classes .= ' simcal-today simcal-present simcal-day';
} elseif ($timestamp < $now) {
$day_classes .= ' simcal-past simcal-day';
} elseif ($this->end > $now) {
$day_classes .= ' simcal-future simcal-day';
}
$count = 0;
foreach ($events as $day_events) {
foreach ($day_events as $event) {
if ($event instanceof Event) {
$event_classes = $event_visibility = '';
$calendar_class = 'simcal-events-calendar-' . strval($event->calendar);
$calendar_classes[] = $calendar_class;
$recurring = $event->recurrence ? 'simcal-event-recurring ' : '';
$has_location = $event->venue ? 'simcal-event-has-location ' : '';
$event_classes .= 'simcal-event ' . $recurring . $has_location . $calendar_class;
// Toggle some events visibility if more than optional limit.
if ($calendar->events_limit > -1 && $count >= $calendar->events_limit) {
$event_classes .= ' simcal-event-toggled';
$event_visibility = ' style="display: none"';
}
$event_color = '';
$bullet = '';
$event_color = $event->get_color();
if (!empty($event_color)) {
$side = is_rtl() ? 'right' : 'left';
$event_color = ' style="border-' . $side . ': 4px solid ' . $event_color . '; padding-' . $side . ': 8px;"';
}
$list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . $event_color . ' itemprop="event" itemscope itemtype="http://schema.org/Event">' . "\n";
$list_events .= "\t\t" . '<div class="simcal-event-details">' . $calendar->get_event_html($event) . '</div>' . "\n";
$list_events .= "\t" . '</li>' . "\n";
$count++;
// Event falls within today.
if ($this->end <= $now && $this->start >= $now) {
$day_classes .= ' simcal-today-has-events';
}
//.........这里部分代码省略.........
示例5: isToday
protected function isToday($date)
{
$dt = new Carbon($date);
return $dt->isToday();
}
示例6: ivy_echo_date
function ivy_echo_date(\Carbon\Carbon $date)
{
$date->setTimezone(config('params.user_timezone'));
return $date->isToday() ? 'Mới @' . $date->format(config('params.user_hourformat')) : ($date->isYesterday() ? 'Hôm qua @' . $date->format(config('params.user_hourformat')) : $date->format(config('params.user_dateformat')));
}
示例7: feedsAndCategories
public static function feedsAndCategories()
{
\DB::enableQueryLog();
$oQuery = DB::table('categories')->join('feed_user', function ($join) {
$join->on('categories.id', '=', 'feed_user.category_id')->where('categories.user_id', '=', Auth::id());
})->join('feeditems', function ($join) {
$join->on('feed_user.feed_id', '=', 'feeditems.feed_id');
if (Request::has('feed')) {
$join->where("feeditems.feed_id", "=", Request::get('feed'));
}
})->join('feeds', "feeds.id", "=", "feed_user.feed_id");
$oQuery->orderBy('feeditems.pubDate', 'desc')->select(['feeditems.url as url', 'feeditems.title as title', 'feeds.url as feedurl', 'feeds.id as feed_id', 'feeditems.pubDate as date', 'feed_user.name as name', 'feeditems.thumb as thumb', 'feeds.thumb as feedthumb', 'feed_user.colour as feed_colour', 'categories.id as cat_id']);
$iPage = Request::input("page", 1);
$iPerPage = 20;
$iTotalItems = 0;
//$maFeedItems = $oQuery->skip(($iPage * $iPerPage)-$iPerPage)->take($iPerPage)->get();
$maFeedItems = $oQuery->get();
#print_r($maFeedItems);die();
$iTotalItems = count($maFeedItems);
$iTotalPages = ceil($iTotalItems / $iPerPage);
$maFeedItems = array_slice($maFeedItems, $iPage * $iPerPage - $iPerPage, $iPerPage);
#print_r(DB::getQueryLog());
$oaFeedItems = [];
foreach ($maFeedItems as $oFeedItem) {
$sDate = '';
$oDate = new Carbon($oFeedItem->date);
if ($oDate->isToday()) {
// 10:41 pm
$sDate = $oDate->format('g:i a');
} else {
// Aug 12
$sDate = $oDate->format('M j');
}
array_push($oaFeedItems, ["url" => $oFeedItem->url, "title" => $oFeedItem->title, "feedurl" => $oFeedItem->feedurl, "feed_id" => $oFeedItem->feed_id, "category_id" => $oFeedItem->cat_id, "date" => $sDate, "name" => $oFeedItem->name, "thumb" => $oFeedItem->thumb !== '' ? $oFeedItem->thumb : $oFeedItem->feedthumb, "feed_thumb" => $oFeedItem->feedthumb]);
}
if (Request::has('feed')) {
$oQuery->where("feeds.id", "=", Request::get('feed'));
}
$oUser = Auth::user();
$oUser->load('userCategories.userFeeds.feed');
#$oaFeeds = Auth::user();->userCategories()->userFeeds;
//$oaFeeds = $oUser->userCategories->userFeeds->feed;
#foreach()
// what to return
// categories / feed structure
// array of feed items
$oData = ['iAvailablePages' => $iTotalPages, 'iPerPage' => $iPerPage];
$oaCategoryFeeds = [];
foreach ($oUser->userCategories as $oCategory) {
// get feeds in category
$aoFeeds = [];
foreach ($oCategory->userFeeds as $oUserFeed) {
array_push($aoFeeds, ["id" => $oUserFeed->id, "name" => $oUserFeed->name]);
}
// now add category with feeds
array_push($oaCategoryFeeds, ["category_id" => $oCategory->id, "category_name" => $oCategory->name, "feeds" => $aoFeeds]);
}
return response()->json(['jsonFeedItems' => $oaFeedItems, 'jsonCategoryFeeds' => $oaCategoryFeeds, 'data' => $oData]);
//return response(['jsonFeedItems' => $oaFeedItems, 'jsonFeeds' => $oaFeeds], 200);
}
示例8: Carbon
<?php
use Carbon\Carbon;
if (count($events)) {
?>
@foreach ( $events as $key => $value )
<div class="list-group-item disabled">
<span class="text-uppercase">
<?php
$dt = new Carbon($key);
?>
<?php
if ($dt->isToday()) {
echo "<strong>hoje</strong>, " . strftime("%A %d de %B", strtotime($key));
} else {
if ($dt->isTomorrow()) {
echo "<strong>amanhã</strong>, " . strftime("%A %d de %B", strtotime($key));
} else {
if ($dt->isYesterday()) {
echo "<strong>ontem</strong>, " . strftime("%A %d de %B", strtotime($key));
} else {
echo strftime("%A, %d de %B", strtotime($key));
}
}
}
?>
</span>
</div>
@foreach ( $value as $event )