yii2-user icon indicating copy to clipboard operation
yii2-user copied to clipboard

A suggestion regarding datetime handling

Open yairpe opened this issue 8 years ago • 2 comments

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

yairpe avatar May 03 '17 14:05 yairpe

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.

amnah avatar May 05 '17 23:05 amnah

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

FedericoBenedetti1976 avatar Dec 03 '17 23:12 FedericoBenedetti1976