Skip to content

Commit 47c9459

Browse files
committed
Take the "display timezone" into account when setting Carbon string format
1 parent 98ba843 commit 47c9459

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Generator.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,9 @@ protected function makeContentGenerationClosures($pages, $request)
271271
$oldCarbonFormat = $this->getToStringFormat();
272272

273273
if ($this->shouldSetCarbonFormat($page)) {
274-
Carbon::setToStringFormat(Statamic::dateFormat());
274+
Date::setToStringFormat(function (Carbon $date) {
275+
return $date->setTimezone(config('statamic.system.display_timezone'))->format(Statamic::dateFormat());
276+
});
275277
}
276278

277279
$this->updateCurrentSite($page->site());
@@ -489,7 +491,7 @@ protected function shouldRejectPage($page, $outputError = false)
489491
*
490492
* @throws \ReflectionException
491493
*/
492-
protected function getToStringFormat(): ?string
494+
protected function getToStringFormat(): string|\Closure|null
493495
{
494496
$reflection = new ReflectionClass($date = Date::now());
495497

0 commit comments

Comments
 (0)