How to get UTC time in my program?
조회 수: 126 (최근 30일)
이전 댓글 표시
Dear All,
I am wondering if it is pissible to get the UTC time in my program. Do I need the internet avaibale if I want to get UTC time?
Thanks a lot.
Benson
댓글 수: 0
채택된 답변
Star Strider
2020년 7월 12일
Try this:
dtLCL = datetime('now', 'TimeZone','local') % Current Local Time
dtUTC = datetime(dtLCL, 'TimeZone','Z') % Current UTC Time
That will give you both the local time and the corresponding UTC time.
.
댓글 수: 5
Charalambos Hadjipanayi
2023년 2월 1일
This gives you a simple network time, which does not rely on local computer time:
url_time = webread('http://worldtimeapi.org/api/timezone/Etc/UTC')
추가 답변 (1개)
Vini Lima
2022년 3월 25일
utc_time = datetime('now', 'timezone', 'utc')
댓글 수: 1
Charalambos Hadjipanayi
2023년 2월 1일
This just converts your local computer time to UTC. So if your local computer time is incorrect for any reason, the utc_time will be also incorrect.
참고 항목
카테고리
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!