Matlab : datestr predefined date formats ISO8601

2k views Asked by At

When I look at ISO8601 Wikipedia's page, ISO8601 date should be "yyyy-MM-ddTHH:mm:ss" where matlab's documentation predefined "yyyymmddTHHMMSS" which is not corresponding to ISO8601 :

  • is there a mistake in matlab ?
  • did the iso8601 recently changed ?

The solution I use is :

datestr(now,'yyyy-MM-ddTHH:mm:ss') %instead of datestr(now,30)

But it does not look really "clean" for me ...

in addition, I don't understand about 'Z' parameter at the end. Is it supposed to appear if it is not UTC time ? why Matlab doesn't show it ? how to configure this ?

Thank you

1

There are 1 answers

0
droid192 On

how about this:

t = datetime('now', 'TimeZone', 'UTC')
datestr(t,'yyyy-mm-ddTHH:MM:ss.FFFZ')

results in

'2017-10-29T10:30:55.488Z'

e.g. in Javascript import string (send over websocket) with

new Date('2017-10-29T10:30:55.488Z')