How to humanize date&time format in array of objects?

Hi all,

please could someone help me, how to humanize "created" property (for example: YYYY-MM-DD HH:mm) in whole array of objects on screenshot?
It is output of MySQL node.

Many thanks.

Try a function node with ..

msg.payload.forEach(e => {
  e.created = (new Date(e.created)).toString(); 
})
return msg;

I suspect this one is better suited to a change node & moment in JSONata

(Untested, written on mobile)

or do the Date convertion directly in mySql query using DATE_FORMAT(date , format )

For Example

SELECT *, DATE_FORMAT(created, '%Y-%m-%d %H:%i:%s') as created FROM events ORDER BY id DESC LIMIT 50)

1 Like

Thank you, I like this solution.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.