getMidnight()function

getMidnight(target?: PossibleDate, caller: AnyCaller = getMidnight): Date
ParamType
targetPossibleDate
The date to find midnight for (defaults to "now").
callerAnyCaller
The function to attribute a thrown error to (defaults to getMidnight). Defaults to getMidnight
Return
Date
A new Date instance at midnight of the target date.
Throws
RequiredError
If target couldn't be converted to a valid date.

Get a Date representing exactly midnight of the specified date.

Examples

getMidnight("2003-09-12") // Date instance for 2003-09-12 at 00:00