diff --git a/src/Support/Utils.php b/src/Support/Utils.php index 2b341c79..089502c4 100644 --- a/src/Support/Utils.php +++ b/src/Support/Utils.php @@ -15,6 +15,18 @@ class Utils { + /** + * Get the timezone from Carbon. + * + * @return string + */ + protected static function getTimezone() + { + $tz = Carbon::now()->getTimezone()->getName(); + + return in_array($tz, timezone_identifiers_list()) ? $tz : 'UTC'; + } + /** * Get the Carbon instance for the current time. * @@ -22,7 +34,7 @@ class Utils */ public static function now() { - return Carbon::now('UTC'); + return Carbon::now(static::getTimezone()); } /** @@ -33,7 +45,7 @@ public static function now() */ public static function timestamp($timestamp) { - return Carbon::createFromTimestampUTC($timestamp)->timezone('UTC'); + return Carbon::createFromTimestampUTC($timestamp)->timezone(static::getTimezone()); } /**