Correct way to format Date as string to be consumed by Plotly.js?

I’ve noticed that when I want to update range on an axis with date type, I must provide the dates as strings. With Date objects it does not work (see codepen.

However parsing and formatting Date strings is quite tricky (taking into account zones and UTC). Normally I use moment.js for handling Dates to avoid the hell.

What is the recommended formatting function I should use with Plotly.js?



This link does not help because they only mention using Date objects and the issue mentioned is that date objects do not work for JS