How to find the absolution date?

1 回表示 (過去 30 日間)
Benson Gou
Benson Gou 2020 年 6 月 9 日
コメント済み: Benson Gou 2020 年 6 月 9 日
Dear All,
I think it is hard to find out the absolute date (current date). Because the computer date can be changed, for example, today is June 09, 2020, if I run datetime, it could find June 09, 2020. But if I change my computer date to 09 May 2020, datetime will give me 09 May 2020 which is Not the correct date of today. Is there a way to solve this problem?
Thanks a lot.
Benson

採用された回答

David Hill
David Hill 2020 年 6 月 9 日
A simple search showed several possible solutions.
s1 = webread('https://tycho.usno.navy.mil/cgi-bin/timer.pl');
s2 = regexp(s1, '<BR>(.*)\sUTC','tokens','once');
t = datetime(s2,'InputFormat','MMM. dd, HH:mm:ss');
  1 件のコメント
Benson Gou
Benson Gou 2020 年 6 月 9 日
Hi, David,
Thanks for your help. I run your code and got the followinf error message:
Error using webread (line 122)
The connection to URL 'https://tycho.usno.navy.mil/cgi-bin/timer.pl' timed out after 5.000 seconds. The reason is "Connection timed out after
5103 milliseconds". Perhaps the server is not responding or weboptions.Timeout needs to be set to a higher value.
Error in MainSEGNDSE01 (line 20)
s1 = webread('https://tycho.usno.navy.mil/cgi-bin/timer.pl');
Benson

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeJust for fun についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by