Reputation: 3272
I'd like to get the system-time inclusive the milliseconds. Therefore I use this method to get the system-time:
1)
var dt = JSON.stringify(new Date());
The dateToString method only returns the date-format with minutes, not the seoonds and milliseconds
2)
navigator.globalization.dateToString(
new Date(),
function (date) { alert('date: ' + date.value + '\n'); },
function () { alert('Error getting dateString\n'); },
{ formatLength: 'short', selector: 'date and time' }
);
My system-time is 13:07
returns
11:07:44...
returns
13:07
Is it possible to get the seconds and milliseconds from the dateToString method?
Upvotes: 0
Views: 199
Reputation: 5376
JavaScript's Date() has a lot of methods that can help you, like getMilliseconds()
which will return....the number of milliseconds. There is also getMinutes
, getSeconds
, etc. See the full list here:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
Upvotes: 1