diff --git a/README.md b/README.md index a55ecdd87..d274b39b6 100644 --- a/README.md +++ b/README.md @@ -4286,7 +4286,7 @@ formatDuration(34325055574); // '397 days, 6 hours, 44 minutes, 15 seconds, 574 Returns a string of the form `HH:MM:SS` from a `Date` object. -Use `Date.prototype.toString()` and `String.prototype.slice()` to get the `HH:MM:SS` part of a given `Date` object. +Use `Date.prototype.toTimeString()` and `String.prototype.slice()` to get the `HH:MM:SS` part of a given `Date` object. ```js const getColonTimeFromDate = date => date.toTimeString().slice(0, 8); diff --git a/docs/date.html b/docs/date.html index 419f74d0d..05057e39e 100644 --- a/docs/date.html +++ b/docs/date.html @@ -110,7 +110,7 @@ };
formatDuration(1001); // '1 second, 1 millisecond'
 formatDuration(34325055574); // '397 days, 6 hours, 44 minutes, 15 seconds, 574 milliseconds'
-

getColonTimeFromDate

Returns a string of the form HH:MM:SS from a Date object.

Use Date.prototype.toString() and String.prototype.slice() to get the HH:MM:SS part of a given Date object.

const getColonTimeFromDate = date => date.toTimeString().slice(0, 8);
+

getColonTimeFromDate

Returns a string of the form HH:MM:SS from a Date object.

Use Date.prototype.toTimeString() and String.prototype.slice() to get the HH:MM:SS part of a given Date object.

const getColonTimeFromDate = date => date.toTimeString().slice(0, 8);
 
getColonTimeFromDate(new Date()); // "08:38:00"
 

getDaysDiffBetweenDates

Returns the difference (in days) between two dates.

Calculate the difference (in days) between two Date objects.

const getDaysDiffBetweenDates = (dateInitial, dateFinal) =>
   (dateFinal - dateInitial) / (1000 * 3600 * 24);