getTimesfunction
The Sun's times for a day at a place.
Import it
import { getTimes } from "@johnmorrisdotca/wakusei-planets/suncalc";
Definition
function getTimes(date: Date | number, lat: number, lng: number, height?: number, utcOffset?: number): SunTimes
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). |
height (optional) | number | The observer's height above the horizon in metres (default 0): it lowers the sunrise and sunset altitudes by the dip of the horizon. |
utcOffset (optional) | number | undefined | Minutes east of UTC: when given the day is the local calendar day holding |
Returns
SunTimes
The times as Dates, null for one that does not happen that day, and alwaysUp or alwaysDown at the poles.
Examples
import { getTimes } from "@johnmorrisdotca/wakusei-planets/suncalc";
const t = getTimes(new Date(Date.UTC(2026, 5, 21, 12)), 51.5, -0.1, 0, 60);
console.log(t.sunrise!.toISOString().slice(0, 13));2026-06-21T03What it prints (run when this page was built)