amnah / yii2-user

Yii2 user authentication module
MIT License
253 stars 104 forks source link

A suggestion regarding datetime handling #188

Open yairpe opened 7 years ago

yairpe commented 7 years ago

Right now, the user tables are using mysql TIMESTAMP integer and gmdate("Y-m-d H:i:s") in the code.

To avoid the 1970-2038 limitation (20 years from now), I believe it's better to use DATETIME field and use (new \DateTime('NOW'))->format('Y-m-d H:i:s')

mysql knows to preserve the current date&time values when switching from TIMESTAMP to DATETIME

amnah commented 7 years ago

This is an extreme edge case ... a far majority of apps built today won't exist 20 years from now. I'd be amazed if any did lol.

Anyhow, if they ever get there they can convert it when the time comes. We'll have a big panic similar to y2k and everyone will be aware of it.

FedericoBenedetti1976 commented 6 years ago

A gmdate is a GMT date :( and not a date in my timezone (Europe/Rome) so when it save for example: $this->logged_in_at = gmdate("Y-m-d H:i:s"); i have: real time 00:55, database saved time with gmdate: 23:53