Black Lives Matter. Please consider donating to Black Girls Code today.

How to convert date into plotly timestamp

Hey there,

I’m currently working with dates and running into some issues.

Let’s say we have the following date 2020-01-28T13:36:47.720080+00:00. The value related to this date is displayed correctly in the chart. What I want to achieve is to trigger a hover event via Plotly.Fx.hover(xval: xvalue) but it seems like to get that to work I’d need the corresponding timestamp in milliseconds. So Plotly can create the unix timestamp in milliseconds with microseconds appended (milliseconds.microseconds) but most of the for me familar libraries only return the milliseconds rounded (i.e moment, date object, …). How does plotly generate this timestamp? Am I using moment, date object wrong?

EDIT: It also seems like plotly.js does not take the zone into account and just displays the timestamp of the current time zone…

Thanks
Mirko