dateToArray(date) milliseconds


Using builtin functions instead of custom functions is better, as I read in the doc.

Now the builtin function dateToArray doesn't include the milliseconds, so what do you suggest if I want the milliseconds to be included in my view for sorting?

Example in doc:

Your help will be appreciated


1 Answer

« Back to question.

Since the Milliseconds are independent from other date parsing I would go for grabbing them off the parsed date separately and append them to the array. Something like this:

 function (doc, meta) {
  if(doc.type === "datetest") {
    var dateArray = dateToArray(;
    var ms = new Date(;

This keeps all the other elements consistent with the way dateToArray handles them but appends the Milliseconds as needed.