How to set timestamp to 0


#1

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...


#2

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.


#3

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


#4

Why not use NULL for undefined?


#5

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


#6

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


#7

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


#8

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


#9

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