The time stamp I used previously was from the template, and it doesn't show time very well. For example, 2009-07-21T13:06:44.670Z, a little hard to read. This is done using System.currentTimeMillis() from java.util.Date, which gives time to milliseconds, and was stored in mysql as a BIGINT.To the left is screenshot of type datestamp from metadata table, stored in BIGINT and created by System.currentTimeMillis().
However, there's a smart way to do this: mysql have a build-in type: TIMESTAMP, which will be responsible to keep track of time and display it properly when called. It can be called using command NOW(). This screenshot is date from users table, stored in TIMESTAMP and created by NOW().
Update:
Although it looks much neater, with 2nd method. The TIMESTAMP is more like a String, and losses it's ability to sort metadata by time. On the other hand, I don't need it for that function.


No comments:
Post a Comment