Problem with parse a string to DateTime

from an application I get the date in the format "20111230T213000Z", how can I convert it in a function to a DateTime object to calculate with it etc.?
var d = new Date('20111230T213000Z') does not work.


It tends to be time string but somehow proper format is lost .
The string format should be: YYYY-MM-DDTHH:mm:ss.sssZ
If you cant get properly formatted string from source, you need to break this string into parts to make your time object. There is many ways to do this.
As you are already using the function node, so do it by using string extracting methods.

Hello hotNipi,
thanks for your fast answer. I tried it:

var d = new Date('2019-02-06T05:00:00.000Z');
var year = d.getYear();  
var month = d.getMonth();

but year is "119" and month ist "1"


It might be worth re-reading

1 Like

Yes, it works, thank you very much.

Also check out the node-red-contrib-moment node if you need a node for date/time conversions and simple calculations.