mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
set timezone
This commit is contained in:
32
app/Support/Carbon.php
Normal file
32
app/Support/Carbon.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
class Carbon extends CarbonImmutable
|
||||
{
|
||||
public function asDate(): string
|
||||
{
|
||||
$dt = $this->timezone(config('app.timezone'))->locale('de');
|
||||
return str($dt->day)->padLeft(2, '0').'. '.$dt->monthName.' '.$dt->year;
|
||||
}
|
||||
|
||||
public function asTime(): string
|
||||
{
|
||||
return $this->timezone(config('app.timezone'))->locale('de')
|
||||
->format('H:i');
|
||||
}
|
||||
|
||||
public function asDateTime(): string
|
||||
{
|
||||
$dt = $this->timezone(config('app.timezone'))->locale('de');
|
||||
return sprintf("%s. %s %s %s (%s)",
|
||||
str($dt->day)->padLeft(2, '0'),
|
||||
$dt->monthName,
|
||||
$dt->year,
|
||||
$dt->format('H:i'),
|
||||
$dt->timezone
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user