I have a epoch/unix timestamp which I have, which I get after running the journalctl -o json-pretty -f
command. So I get my "__REALTIME_TIMESTAMP" : "1576681153604871"
value from a given log. I want to convert this to an ISOString format, so I use the below code
var result;
time = parseInt(time);
var msec = time/1000; // convert __REALTIME_TIMESTAMP to milliseconds from microseconds
var myDate = new Date(msec);
var isoDate = myDate.toISOString();
I get the output as below
"2019-12-18T14:25:49.605Z"
I wish to even display the microsecond part in this something like
"2019-12-18T14:25:49.605762Z"
but myDate.toISOString()
doesn't work properly if I don't convert the epoch to milliseconds.
I dont know if time % 1000
is the right way, to extract the microsecond part and then append it to get the desired output .
So is there a way to get the output in microsecond format ?