SQL To get the Server Timezone.


/ Published in: SQL

The below code has 2 snippets. to find the time difference from the current zone and the other is to find the timezone of the server


Copy this code and paste it in your HTML
  1. SELECT
  2. SYSDATETIME() AS curdatetime,
  3. DATENAME(TZoffset, SYSDATETIMEOFFSET()) AS curtzoffsetstr,
  4. DATEPART(TZoffset, SYSDATETIMEOFFSET()) AS curtzoffsetint;
  5.  
  6. DECLARE @tzname AS sysname;
  7.  
  8. EXEC master.dbo.xp_regread
  9. 'HKEY_LOCAL_MACHINE',
  10. 'SYSTEM\CurrentControlSet\Control\TimeZoneInformation',
  11. 'TimeZoneKeyName',
  12. @tzname OUTPUT;
  13.  
  14. SELECT @tzname;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.