Hi,
I need to convert a timestamp to GMT which depends on the TimeZone. This is read out of a variable which was in this case 'Europe/Berlin'. The timestamp has to be sent as a request in GMT time and will be sent back (both as posixtime). The backtransformation from posixtime to the timezone read out of the variable is working:
datetime(1565618481,'TimeZone','Europe/Berlin','ConvertFrom','posixtime',"TicksPerSecond",1000,'Format','dd-MMM-yyyy HH:mm:ss.SSS Z')
For the request I wanted to define a datetime vektor of the local time with the timezone and convert it then to GMT to make the posixtime vektor afterwards. In the following code the same timezone was not working:
datetime('22.07.2019 21:00:00','InputFormat','TimeZone','Europe/Berlin','dd.MM.yyyy HH:mm:ss Z')
I always get the Error:
Error using datetime (line 538)
Invalid parameter name: Europe/Berlin.
Can anyone help me why this is the case and how I can make it work?
Thank you,
Manuel

 採用された回答

Star Strider
Star Strider 2019 年 8 月 12 日

2 投票

You need to put the format string just after the 'InputFormat' name (they are ‘name-value pair’ arguments), and also use the 'Z' designator in the time string.
Try this:
tq = datetime('22.07.2019 21:00:00 Z','TimeZone','Europe/Berlin','InputFormat','dd.MM.yyyy HH:mm:ss Z')
producing:
tq =
datetime
22-Jul-2019 23:00:00

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Dates and Time についてさらに検索

質問済み:

2019 年 8 月 12 日

回答済み:

2019 年 8 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by