How can I set the time zone of a datetime object using a numerical offset?
조회 수: 2 (최근 30일)
이전 댓글 표시
I have an application where the user will identify a time zone by the offset from UTC in hours. He'll be defining a range of times in UTC as well, and I'd like to be able to create the corresponding datetime array for his designated time zone, so I'd like to be able to do this using the numerical value he input for the offset.
I can convert the number of hours to a properly formatted string and set that as the value of the TimeZone property, but it seems like there could be a simpler way to do it using the numerical value directly (as a duration, most likely) - sort of the opposite of the tzoffset function.
Can this be done?
댓글 수: 4
Peter Perkins
2015년 11월 6일
If all they specify is an offset from UTC, you have no hope to turn that into a civil time zone without making strong assumptions. If you're willing to do that, the timezones function might be helpful.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!