1

Given this simple table:

create table comments (
  id numeric not null,
  comment text, 
  created timestamp not null default now()
);

Using dbeaver directly on the db from my pc, and executing this statement

insert into comments (id, comment)
select 1111, 'test';

the "created" field of the new record is: 2017-02-24 16:17:21 and that's my correct time (CET).

When I run the very same statement from a php script (running on a linux-based webserver connected to the db), the result is 2017-02-24 15:17:21. The linux server time is ok (that is, CET).

What am I missing?

1 Answers1

0

As per the answer at this link, change your table definition to

create table comments (
   id numeric not null,
   comment text, 
   created timestamp not null default (now() at time zone ('CET'))
);

which will use the current datetime using the desired time zone.

Community
  • 1
  • 1
Andy
  • 698
  • 12
  • 22