Step 1 is always look on flows.nodered.org and see if someone else has published a flow you can borrow bits from or a node that does what you want.
On the javascript date, it’s a common problem, so if step 1 doesn’t help there are thousands of answers on google.