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