Oracle 10g Time Zone Confusion

后端 未结 3 512
后悔当初
后悔当初 2020-12-30 16:38
SELECT TO_CHAR(SYSDATE, \'YYYY-MM-DD HH24:MI\')
      ,TO_CHAR(CURRENT_DATE, \'YYYY-MM-DD HH24:MI\')
      ,TO_CHAR(SYSTIMESTAMP, \'YYYY-MM-DD HH24:MI TZR\') 
               


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-30 17:11

    Use UTC time and offset your timezone from UTC, To get UTC in Oracle use SYS_EXTRACT_UTC

    Convert SYSTEMDATE to UTC

        select sys_extract_utc(systimestamp) from dual;
    

    As for the difference the definition from Oracle documentation might help to explain:

    • LOCALTIMESTAMP returns the current date and time in the session time zone in a value of datatype TIMESTAMP
    • CURRENT_TIMESTAMP returns the current date and time in the session time zone, in a value of datatype TIMESTAMP WITH TIME ZONE
    • SYSTIMESTAMP returns the system date, including fractional seconds and time zone, of the system on which the database resides
    • CURRENT_DATE returns the current date in the session time zone, in a value in the Gregorian calendar of datatype DATE.
    • SYSDATE returns the current date and time set for the operating system on which the database resides.
    • DBTIMEZONE returns the value of the database time zone.

提交回复
热议问题