jquery - Include millisecond data in JavaScript Date -


i have requirement send current system date microservices on search. time should include milliseconds information well. sending new date() same , looked like:

thu aug 31 2017 15:06:37 gmt+0530 (india standard time) 

however need milliseconds information time should like:

thu aug 31 2017 15:06:37.228 gmt+0530 (india standard time) 

here 228 millisecond @ moment can extract using getmilliseconds() method of date. question how can add in date works locations wherever application accessed?

if don't mind having result string, show output looking for:

// es5  var fmtdatemses5 = function(date) {    var splitdate = date.tostring().split(' ');    splitdate[4] = splitdate[4] + '.' + date.getmilliseconds();    return splitdate.join(' ');  }    // log output (es5)  console.log('es5 output\n', fmtdatemses5(new date()));      // es6  const fmtdatemses6 = date => {    const splitdate = date.tostring().split(' ');    splitdate[4] = `${splitdate[4]}.${date.getmilliseconds()}`;    return splitdate.join(' ');  };    // log output (es6)  console.log('es6 output\n', fmtdatemses6(new date()));      // es5 , es6 functions logged simultaneously  console.log(    `\nes5 , es6 functions logged simultaneously`,    `\n${'-'.repeat(55)}`,    `\nes5 output ${fmtdatemses5(new date())}`,    `\nes6 output ${fmtdatemses6(new date())}`  );


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -