Search code examples
datetimepostgresqlepoch

How to add integer column with default of unix timestamp (epoch) in PostgreSQL?


This doesn't work:

create table event (
...
time int default date_part('epoch', timestamp 'now'),
...
);

Solution

  • I'm no postgresql expert but shouldn't this one work

    time int default date_part('epoch', now())