Convert GMT datetime to local

前端 未结 4 1538
误落风尘
误落风尘 2021-01-22 19:05

I have a datetime value in GMT timezone. How can I convert it to my local timezone? I would expect there to be a function for this. Please note that I can not just add or subtra

4条回答
  •  一整个雨季
    2021-01-22 19:43

    I have a datetime value in GMT timezone. How can I convert it to my local timezone? I would expect there to be a function for this. Please note that I can not just add or subtract the difference, because of the summertime.

    There is a function for that:

    TZONEU2S Function Converts a UTC date time value to a SAS date time value. http://documentation.sas.com/?docsetId=nlsref&docsetTarget=n1ien0skr1u9swn1f00w7hizdg9c.htm&docsetVersion=9.4&locale=en

    When you specify a zone ID, the time zone that SAS uses is determined by the time zone name and daylight savings time rules.

    Example:

    data;
      do d = 20 to 30;
        date = '28FEB2018'd + d;
        dt = dhms(date, 12, 0, 0);
        dt2 = tzoneu2s(dt,'EUROPE/LONDON'); 
        output;
      end;
      format date E8601DA. dt dt2 E8601DT. ;
    run;
    
    proc print;
    run;
    

提交回复
热议问题