How to set timestamp to 0

Hey guys!

I tried to set my timestamp to undefined as 0 and for some of my other tables, this is working but not for others… Is it possible to do this? I even tried to do something like this in my php code: $date = 0; but that doesn’t work all the time…

This doesn’t really make sense without any code. Databases can handle integers, including zero, so can PHP - but nobody should use this for date representation (except for very good reasons). Timestamp has gone really unimportant.

What tables? tables are either a thing of HTML or a database, both of them are only marginally related to PHP.

Why not use NULL for undefined?

1 Like

I tried it with null but then it wouldn’t allow me to update it later… i think it will always be null…

That would have been a programming error. You can always update NULL to a new real value.

I will try to update but did try to insert a value into null and it didn’t work…

Well that depends whether the column is nullable or not. If its not then indeed you can’t insert null. If it is then you can.

See https://dev.mysql.com/doc/refman/8.0/en/working-with-null.html

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.