Carbon::create(2023,9,27,0,0,'Europe/Istanbul');
now()->toTimeString()
{{ $post->published_at->toFormattedDateString() }}
{{ $comment->created_at->format('M j, Y \a\t g:i a') }}
\Carbon\Carbon::parse($company->type_end_date)->translatedFormat('j F Y, H:i')
Carbon::parse($classroom->start_date)->addWeeks($key);
Carbon::today()->dayOfWeek
\Carbon\Carbon::now()->endOfMonth()->addYear(1)->translatedFormat('j F Y')
Carbon::now()->weekOfYear
$trWeekDays = [
0 => 7, // pazar
1 => 1, // pazartesi
2 => 2,
3 => 3,
4 => 4,
5 => 5,
6 => 6,
];
return $trWeekDays[Carbon::today()->dayOfWeek];
$now = Carbon::now();
$hafta_baslangici = $now->startOfWeek(Carbon::TUESDAY);
$hafta_sonu = $now->endOfWeek(Carbon::MONDAY);
$weekStartDate = $hafta_baslangici->format('Y-m-d H:i'); // string(16) "2021-10-02 00:00"
$weekEndDate = $hafta_baslangici->format('Y-m-d H:i'); // string(16) "2021-10-08 23:59"
'timezone' => 'Europe/Istanbul',
'locale' => 'tr_TR',
'fallback_locale' => 'tr',
Şimdi de Türkçe için formatlayalım.
return \Carbon\Carbon::parse($this->created_at)->translatedFormat('j F Y, l H:i');
\Carbon\Carbon::parse($field->updated_at)->diffForHumans()
now()->subHour()
Datetime olmayan bir sütun değerini Datetime'a dönüştürmek için ->withCasts(['sütun_adı' => 'tipi']) metodunu kullanabiliriz.
$user = User::query()
->addSelect(['last_login_at' => Login::select('created_at')
->where('user_id', 'users.id')
->latest()
->take(1)
])
->withCasts(['last_login_at' => 'datetime'])
->orderBy('name')
->paginate();
$q->whereDate('created_at', '=', date('Y-m-d'));
// veya
$q->whereDate('created_at', '=', Carbon::today()->toDateString());
$q->whereDay('created_at', '=', date('d'));
$q->whereMonth('created_at', '=', date('m'));
$q->whereYear('created_at', '=', date('Y'));
<input class="form-control" type="datetime" name="timestamp" value="{{ $chapter->created_at }}">
<div class="form-group">
<label for="start_date">Abonelik Başlangıç:</label>
<input type="date"
class="form-control"
id="start_date"
name="start_date"
value="{{ \Carbon\Carbon::parse($subscription->start_date)->translatedFormat('Y-m-d') }}">
</div>