mysql - I like the 70's, but that's just not right (PHP Time question) -


So I am storing the hidden field time () call with every entry of my DB. The only problem is that they all come in such a way:

16777215

Which is from the 1970s. I can not tell why it does not have a number, because it is not the beginning or end of the current timestamp, and it is the same for every entry, it is going in a medium (50) MySQL column, and the field looks like this:

  & lt; Input type = "hidden" name = "time" value = "& lt ;? php echo time () ;? & gt;" & gt;  

Is this a casting problem? I bet it is. Sunnova Gun let me check that ...

So I changed the column to "Text" and it was entered correctly. So if I want to have a number to do this math, then I need to use php to change it before saving it? And just for curiosity, why chose that number first?

If you are submitting dates, then I would suggest to use date types created in MySQL too Tax? You can make manual queries very easy by date verification (MySQL, you can not allow to enter the month 13, for example), and while looking at the raw data, you know what's the date MySQL lets you call CURRENT_TIMESTAMP ) That you need to record at the time of a line change.

Storing in the form of an integer makes it easy to do simple math, but I think its advantage is ending at the end of the code. PHP has a strong date / time library which you can use to deal with dates. If you want to see the amount of time between two dates, you can use date :: chunks. You can also add time to dates and reduce dates. (Yes, there are functions to be consistent with the object to decide to use the function instead of the object.)


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -