googleworkspace / php-samples

PHP samples for Google Workspace APIs
Apache License 2.0
288 stars 348 forks source link

Fatal error: Uncaught exception 'Exception' #18

Closed prabhat2k15 closed 6 years ago

prabhat2k15 commented 6 years ago

Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.' in /Library/WebServer/Documents/sheet/vendor/google/auth/src/Cache/Item.php:129 Stack trace:

0 /Library/WebServer/Documents/sheet/vendor/google/auth/src/Cache/Item.php(129): DateTime->__construct('now + 1500 seco...')

1 /Library/WebServer/Documents/sheet/vendor/google/auth/src/CacheTrait.php(61): Google\Auth\Cache\Item->expiresAfter(1500)

2 /Library/WebServer/Documents/sheet/vendor/google/auth/src/Middleware/ScopedAccessTokenMiddleware.php(171): Google\Auth\Middleware\ScopedAccessTokenMiddleware->setCachedValue('https://www.goo...', 'ya29.GlvyBVHIoH...')

3 /Librar in /Library/WebServer/Documents/sheet/vendor/google/auth/src/Cache/Item.php on line 129

sqrrrl commented 6 years ago

From a quick Google search this appears to be a long standing PHP requirement that you explicitly set the timezone for your app.

See https://stackoverflow.com/questions/2213608/php-configuration-it-is-not-safe-to-rely-on-the-systems-timezone-settings

prabhat2k15 commented 6 years ago

yeah...got it resolved by setting timezone manually at top date_default_timezone_set('Europe/London');