How to set the clock from milliseconds?

If I have milliseconds from UTC time, how can I use that to initialize the clock?
I only see JulianDate:

var theclock = new Cesium.Clock({

startTime : Cesium.JulianDate.fromIso8601(“2013-12-25”),

currentTime : Cesium.JulianDate.fromIso8601(“2013-12-25”),

stopTime : Cesium.JulianDate.fromIso8601(“2013-12-26”),

clockRange : Cesium.ClockRange.LOOP_STOP,

clockStep : Cesium.ClockStep.SYSTEM_CLOCK_MULTIPLIER


You can create a JulianDate from a JavaScript Date, and you can create a JavaScript Date from UTC milliseconds, so the simplest answer is:

JulianDate.fromDate(new Date(milliseconds));

The full answer is a bit more nuanced than that. If your milliseconds since 1970 take leap seconds into account then you need to create a JulianDate at 1970 and then add the milliseconds:

var date = JulianDate.fromDate(Date.UTC(1970, 0, 1));

JulianDate.addSeconds(date, milliseconds * 1000, date);

In reality, most systems are incorrect and ignore leap seconds (including JavaScript) so 99.99% of people want the first way, but the second way is required for the use case I described. I just included it for completeness.