set timezone

This commit is contained in:
Benjamin Takats
2022-12-02 16:24:25 +01:00
parent 1c2bf70773
commit 17591d8dbb
18 changed files with 286 additions and 34 deletions

32
app/Support/Carbon.php Normal file
View 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
);
}
}