MATLAB: Determine UTC Offset for a given Time Zone

datetimetime

I am using an API to bring data into Matlab, and the timestamps are in UNIX time format. It also returns the local time zone for the data. UNIX time is based on UTC, so it convert it into a usable timestamp, I need to consider the UTC offset for the given time zone. The problem is, I can't seem to find a way to input a time zone to Matlab and have it output a UTC offset. I know that this information is available, because you can use tzoffset. But that requires a datetime input. Which puts me into a kind of catch-22. In order to convert to a datetime, I need the UTC offset. But to get the UTC offset, I need a datetime.
Is there any function that will tell me the UTC offset if I give it a timezone?

Best Answer

All you need to do is:
>> datetime(1490742843,'ConvertFrom','posixtime','TimeZone','Europe/Paris')
ans =
datetime
29-Mar-2017 01:14:03
You don't say what form your time zone info is in, but datetime is pretty forgiving. See the doc for datetime.TimeZone.