Banning
Banning

Reputation: 2287

Converting to UTC with known timezone offset

Not sure if the title of my question was accurate so sorry if it's misleading, here goes.

I am doing some work with that involves timezones and i just want to make sure i get this right... if i want something to start at 03:00:00 my time and my timezone offset is -5 all i need to do is add 5 to 03:00:00 giving me 08:00:00 and that is the UTC time?

Upvotes: 0

Views: 259

Answers (2)

FrankieTheKneeMan
FrankieTheKneeMan

Reputation: 6810

...Yes. Depending on what language you're doing it in, it may or may not be as easy as writing

time-offset;

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1502825

It depends what you mean by "timezone offset". Usually an offset is expressed as the amount added to UTC to get to local time, in which case you need to subtract it from the local time in order to get back to UTC (so it would be 22:00 on the previous day in your case).

So for example, Pacific Daylight Time has an offset of -7 - it's 7 hours behind UTC.

However, there are situations (annoyingly) where the offset is expressed the other way round, so make sure you know which way is appropriate for your specific context.

Note that knowing the offset doesn't mean you know the time zone - there can be multiple time zones with the same offset for a particular moment, but different rules for when the offset changes.

Upvotes: 2

Related Questions