Convert date time to readable date time

#1

from my database i get to the date and time like this : 2018-09-30T20:36:41.000Z

but i want to to it nice and sexy in a html email like 30 september 2018, 20.36

i tried the format node and some examples from google like below.
but none gives me what i am looking for.
Is this possible with node red ?


https://golb.hplar.ch/2017/01/JavaScript-Date-and-moment-js.html

0 Likes

#2

Hi @RogierQ, take a look at https://flows.nodered.org/node/node-red-contrib-moment - it should be able to help you convert it to any format you want.

1 Like

#3

thanks!

tried that one also.
gives me this error : "Invalid input for humanize call, input must be an integer"

so i tried Number and parseInt but without succes
the exact output is 2018-09-30T12:30:00.000Z from the sql query

0 Likes

#4

I think you are using the Humanize node rather than the moment node (which gives you more options - both come with the contrib-moment library). See the docs for the moment node to see what the input needs to be.

You can send all sorts of data to the moment node. MomentJS is used to make sense of text. A JavaScript date object is inherently understood. If you pass a number it will also be treated as a JavaScript Datetime object - the number of milliseconds since 1/1/1970. That has to be an integer.

The recently updated version of the moment node puts some examples into the library so that you can see how it works.

In terms of your data. Put a debug node on the output from the SQL query to see what format it is actually producing.

Also note that the Humanize node was contributed by someone else and I haven't updated it. Use the actual moment node first. If you can get something out of that, there is likely some processing missing in the Humanize node so I can then look at that and see if I can understand what it is doing.

1 Like