File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515
1616class Utils
1717{
18+ /**
19+ * Get the timezone from Carbon
20+ *
21+ * @return string
22+ */
23+ protected static function getTimezone ()
24+ {
25+ $ tz = Carbon::now ()->getTimezone ()->getName ();
26+
27+ return in_array ($ tz , timezone_identifiers_list ()) ? $ tz : 'UTC ' ;
28+ }
29+
1830 /**
1931 * Get the Carbon instance for the current time.
2032 *
2133 * @return \Carbon\Carbon
2234 */
2335 public static function now ()
2436 {
25- return Carbon::now (' UTC ' );
37+ return Carbon::now (static :: getTimezone () );
2638 }
2739
2840 /**
@@ -33,7 +45,7 @@ public static function now()
3345 */
3446 public static function timestamp ($ timestamp )
3547 {
36- return Carbon::createFromTimestampUTC ($ timestamp )->timezone (' UTC ' );
48+ return Carbon::createFromTimestampUTC ($ timestamp )->timezone (static :: getTimezone () );
3749 }
3850
3951 /**
You can’t perform that action at this time.
0 commit comments