kampanjjakt's avatar

Weird time/timezone-behaviour

I'm building an API, and encounterad a really wierd issue regarding timestamps, on a user object i have the standard created_at and updated_at fields, the timezone is set to UTC, but the value inserted is UTC+2 (my local time), so i started investigated, and if i echo out Carbon::now() i get the correct UTC-time, and i have a custom datetime-field called lastActvity where i put in Carbon::now(), and the time there is correct UTC. Doesn't Lumen use Carbon for their timestamps? Or what could the issue be? I've set the APP_TIMEZONE to UTC in env. If i echo ot the php timezone it's also set to UTC.

Please help me :D

0 likes
4 replies
kampanjjakt's avatar

For example if i crate a new user at 16:05 CET (my local time) The users timestamps will be: created_at = 2015-06-25 16:05:29

If i then create a new match where i have a lastActivity-datetime field at the same time: lastActivity=2015-06-25 14:05:29 - which is correct. Set by Carbon::now()

kampanjjakt's avatar

The timezone on the server is CET, but the .ENV should take priority on this, right? Sorry for spamming, but urgent need to fix this.

kampanjjakt's avatar
kampanjjakt
OP
Best Answer
Level 3

Problem solved by rebooting server, i guess that ENV maybe get cached or something?

afrayedknot's avatar

You need to set

APP_TIMEZONE

and

DB_TIMEZONE

in your .env file.

2 likes

Please or to participate in this conversation.