How to test zero date-time in DB and display it in Nette

Notice: This thread is very old.
ydenda
Member | 21
+
0
-

Hello everyone,

I'd like to have time and date of last login stored in my DB. Default value in DB for each user is
“0000–00–00 00:00:00”. After First login I want to inform user, he is logged in first time. My point is, that representation of zero date and time in DB differs from Nette, which says:
“-0001–11–30 00:00:00”

I expect some beginners fault. In DB is the date stored as timestamp.

Could you please give me a clue, how to successfully test zero date and time in Nette? (if the timestamp is not zero, I'd like to show time and date of last login.)

Should I use different way of date-time handling?

Thank you in advance,
Ydenda

David Matějka
Moderator | 6445
+
+4
-

you should use null in db instead of 0000–00–00 00:00:00 (unless you wanna store jesus christ birth day :))

Last edited by matej21 (2014-09-01 22:20)

ydenda
Member | 21
+
0
-

I don't believe in this guy so I'll rather use NULL, as you suggest.
Neverheless is this happening due to some overflow of variable or is there any other reason?

Thank you for answer.

David Matějka
Moderator | 6445
+
0
-

It is probably some timezone issue

iguana007
Member | 970
+
+3
-

Here is answer to your question: http://stackoverflow.com/…00-00-000000

ydenda
Member | 21
+
0
-

Thank you for that link. Now I see it's bigger than I ever expected :)