Forum Discussion

smpa01's avatar
smpa01
Community Champion
2 years ago
Solved

utc and client offset

how can I dynamically get the offset between utc and client.

 

The follwoing does not work

 

DateTimeZone.UtcNow()-DateTimeZone.LocalNow())

 

I want this to result in -4 as I am in EST.

 

Thank you in advance.

ImkeF AlexisOlson 

  • Some areas are offset by hours and minutes, hence the second line:

    = DateTimeZone.ZoneHours(DateTimeZone.FixedLocalNow()) 
    + DateTimeZone.ZoneMinutes(DateTimeZone.FixedLocalNow()) / 60

2 Replies

  • Some areas are offset by hours and minutes, hence the second line:

    = DateTimeZone.ZoneHours(DateTimeZone.FixedLocalNow()) 
    + DateTimeZone.ZoneMinutes(DateTimeZone.FixedLocalNow()) / 60