getMoonTimesfunction
The Moon's rise, set and transits over a day at a place.
Import it
import { getMoonTimes } from "@johnmorrisdotca/wakusei-planets/suncalc";
Definition
function getMoonTimes(date: Date | number, lat: number, lng: number, utcOffset?: number): MoonTimes
Parameters
| Name | Type | Description |
|---|---|---|
date | number | Date | Any moment of the day, as a |
lat | number | Degrees north, -90 to 90. |
lng | number | Degrees east (west negative). |
utcOffset (optional) | number | undefined | Minutes east of UTC: when given the day is the local calendar day holding |
Returns
MoonTimes
rise, set, transit (the Moon highest) and lowerTransit (lowest) as Dates, each absent on a day without it, with alwaysUp or alwaysDown when the Moon never crosses the horizon.
Examples
import { getMoonTimes } from "@johnmorrisdotca/wakusei-planets/suncalc";
const t = getMoonTimes(new Date(Date.UTC(2026, 10, 7, 12)), 35.7, 139.7, 540);
console.log(Object.keys(t).length > 0);trueWhat it prints (run when this page was built)