MATLAB: How to assign UTC time

MATLABtimezones utc etc/gmt

I have a timetable with data that has UTC +1 as timebase. Matlab provides the function timezones, which nicely shows the region, UTC offset and DST (daylight saving time) options. The data set does not have DST. I noticed that there is a region called "etc.", which doesn't include DST. For example, etc/GMT+1. To my surprise, the UTC offset is -1 and not +1 as I'd expect for, well, GMT +1. Why is it defined in the opposite way? When I look up GMT+1 and UTC+1, they should be the same, shouldn't they? So basically I have two questions: 1 Why does the timezone etc/GMT+1 have a negative UTC offset in Matlab? 2 What is the correct way to assign UTC+1 as timezone to a dataset in a timetable? Is this via etc/GMT-1?

Best Answer

It's a clash of conventions. Isn't it always? Some conventions define east as positive, some as negative. For the timezones function, "the list includes the offset from UTC (in hours, where east is positive)", so to get your timestamp, you take a UTC timestamp and add your offset (see my earlier comment). For reasons I've forgotten, the IANA time zone database uses the convention that west is positive: "In the "Etc" area, zones west of GMT have a positive sign and those east have a negative sign in their name (e.g "Etc/GMT-14" is 14 hours ahead/east of GMT.)"
And elsewhere on that page: "Sign is intentionally inverted." It's confusing. If it helps, you can do either of these as described in the datetime doc):
>> d.TimeZone = '+01:00'
d =
datetime
16-Mar-2017 23:06:01
>> d.TimeZone
ans =
'+01:00'
>> d.TimeZone = 'UTC+1'
d =
datetime
16-Mar-2017 23:06:01
Using a non-DST time zone is a bit unusual, and in some situations will garner you a warning that more or less says, "that time zone doesn't use DST, do you really want that?" I think that by, "The data set does not have DST", you mean that your timestamps are recorded in the local time 1 hour east (if I was a betting man) of UTC without DST adjustments, so I think yes, you really do want that.