Saving time to database in the absence of Zone information

40 Views Asked by At

I process a TEXT log file that contains, among other items, date in this form: 'January 20, 2021 5:26:19 pm'.

I don't have zone information. The system runs in complete isolation, such as offline mode, or no connectivity to the internet. Zero connectivity to the outside world.

I want to save this information to the database for further time comparison such look at logs which are greater than this time. So, I save it to the POSTGRES database in a column of type timestamp. When needed I retrieve from database convert to LocalDataTime and use it.

What is the right way or better way of saving this information to the database?

1

There are 1 best solutions below

0
Bohemian On

If you don't know the timezone, use a zone-less timestamp, which postgres supports:

CREATE TABLE MYTABLE (
    ...
    LOGGED_AT TIMESTAMP WITHOUT TIME ZONE,
    ...
)