Date time conversion problem

'2015-01-01T19:00:00+0100'
'2015-01-01T20:00:00+0100'
I a trying to convert the format to datetime array using a.dates_extracted= datetime(a.dates_extracted,"InputFormat","uuuu-MM-dd'T'HH:mm:ss", "TimeZone", '+0100'); command but I am getting error.
Error using datetime (line 636)
Unable to convert the text to datetime using the format 'uuuu-MM-dd'T'HH:mm:ss'. If the date/time text contain day, month, or time zone names in a language foreign to the 'en_US' locale, those might not be recognized. You can specify a different locale using the 'Locale' parameter.
please help me

回答 (2 件)

Khalid Mahmood
Khalid Mahmood 2021 年 4 月 14 日

1 投票

Don't specify as T19:00:00. Oly T19:00 is enough. Furthermore use T:HH:mmXXX instead of TH:mm:ss
following code works fine.
a.dates_extracted ={'2015-01-01T19:00+01:00';'2015-01-01T20:00+01:00'}
a.dates_extracted = datetime(a.dates_extracted,'InputFormat','uuuu-MM-dd''T''HH:mmXXX','TimeZone','+01:00');

1 件のコメント

Ram Basnet
Ram Basnet 2021 年 4 月 14 日
Thankyou. Its working now.

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

Star Strider
Star Strider 2021 年 4 月 14 日

0 投票

The posted code has errors.
Try this:
A = ['2015-01-01T19:00:00+0100'
'2015-01-01T20:00:00+0100'];
dates_extracted= datetime(A,'InputFormat','uuuu-MM-dd''T''HH:mm:ss+0100','TimeZone','+01:00')
producing:
dates_extracted =
2×1 datetime array
01-Jan-2015 19:00:00
01-Jan-2015 20:00:00
.

4 件のコメント

Ram Basnet
Ram Basnet 2021 年 4 月 14 日
Thankyou so Much its working now
Star Strider
Star Strider 2021 年 4 月 15 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
Derick
Derick 2024 年 8 月 5 日
This is VERY helpful!
Star Strider
Star Strider 2024 年 8 月 5 日
Thank you!
A Vote would be appreciated!

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

カテゴリ

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

製品

リリース

R2019b

質問済み:

2021 年 4 月 14 日

コメント済み:

2024 年 8 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by