Using current time in UTC as default value in PostgreSQL

Using current time in UTC as default value in PostgreSQL

Asked on January 8, 2019 in PostgreSQL.
Add Comment


  • 2 Answer(s)

    This command  no even needed. simply include parentheses around the default expression:

    create temporary table test(
        id int,
        ts timestamp without time zone default (now() at time zone 'utc')
    );
    
    Answered on January 8, 2019.
    Add Comment

    Another one solution:

    timezone('utc', now())
    
    
    Answered on January 8, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.