Reputation: 1527
I don't know why, but I like to work with Unix-timestamp. Maybe because I need to perform calculations with time like with number, e.g. time()-604800.
Right now I have integer column whereto I insert result of time(). I think it isn't right way, is it? Is there a default value -- unix timestamp?
Upvotes: 1
Views: 3920
Reputation: 318508
You should get rid of the habit of using unix timestamps in your database. PostgreSQL has really awesome date functions such as datetimecol - interval '1 week'
. It can also easily convert to unix timestamps using extract(epoch from datetimecol)
.
Anyway, you can use extract(epoch from now())
as the default value of your column.
Upvotes: 11