Here's how to use the endOfDay()
function from date-fns
in JavaScript:
date-fns
module using npm or yarn:index.tsx21 chars2 lines
or
index.tsx18 chars2 lines
endOfDay()
function at the top of your JavaScript file:index.tsx37 chars2 lines
endOfDay()
function with a date object to get the end of the day for that date:index.tsx232 chars4 lines
That's it! The endOfDay()
function returns a new date object that represents the end of the day for the given date. This includes the last millisecond of the day, which is why the time in the output is 23:59:59
.
gistlibby LogSnag