time.sky
when the sun rises and sets and how long the day is anywhere, and the phase of the moon
When the sun rises and sets anywhere on Earth, and the phase of the moon.
A place is given as a city or country (a country means its capital), as a map with lat and lon, or as latitude and longitude, two numbers in degrees, north and east positive. The day defaults to today.
good to know
Section titled “good to know”Times come back in the time zone of the date you pass in, which is your own zone unless you converted it. To get a sunset in the place’s own local time, pass a date in that zone, like date(2026, 6, 21) to "Oslo". With no date, a named city or country uses today in its own zone, and coordinates use today in yours. Near the poles, some days have no sunrise or sunset at all.
Tags: time
sunrisewhen the sun rises at a place on a day, or nil if it doesn’t rise or doesn’t set that daysunsetwhen the sun sets at a place on a day, or nil if it doesn’t rise or doesn’t set that dayday_lengthhow long the sun is up at a place on a day: 0 h if it never rises, 24 h if it never setsmoon_phasethe moon’s phase on a day (today without one), like “full moon”, and how much of it is lit
Functions
Section titled “Functions”sunrise
Section titled “sunrise”sunrise(lat: num, lon: num, day?: date) -> date|nil / sunrise(place: str|map, day?: date) -> date|nil
when the sun rises at a place on a day, or nil if it doesn’t rise or doesn’t set that day
1sunrise(40.71, -74.01, date(2026, 3, 20))2026-03-20 05:59:37 -05:002sunrise({lat: 64.15, lon: -21.94}).hour3See also sunset, day_length
sunset
Section titled “sunset”sunset(lat: num, lon: num, day?: date) -> date|nil / sunset(place: str|map, day?: date) -> date|nil
when the sun sets at a place on a day, or nil if it doesn’t rise or doesn’t set that day
1sunset(51.5, -0.13, date(2026, 12, 21))2026-12-21 09:53:16 -06:002sunset({lat: 59.91, lon: 10.75}, date(2026, 6, 21))2026-06-21 15:43:40 -05:00See also sunrise, day_length
day_length
Section titled “day_length”day_length(lat: num, lon: num, day?: date) -> quantity / day_length(place: str|map, day?: date) -> quantity
how long the sun is up at a place on a day: 0 h if it never rises, 24 h if it never sets
1day_length(0, 0, date(2026, 3, 20)) to h min"12 h 6.66405 min"2day_length(70, 25, date(2026, 6, 21))24 hmoon_phase
Section titled “moon_phase”moon_phase(day?: date) -> str
the moon’s phase on a day (today without one), like “full moon”, and how much of it is lit
1moon_phase()"🌘 waning crescent, 27% lit"2moon_phase(date(2026, 1, 3))"🌕 full moon, 100% lit"See also sunrise
More examples
Section titled “More examples”1# sunset in Paris on the longest day, in Paris time2sunset(48.86, 2.35, date("2026-06-21T12:00+02:00") to "Europe/Paris")2026-06-21 21:57:44 +02:003# the longest day in Oslo4day_length(59.91, 10.75, date(2026, 6, 21)) to h min"18 h 49.9557 min"5# no sunrise at the pole in winter6sunrise(89, 0, date(2026, 12, 21))nil7# the moon on Christmas 20268moon_phase(date(2026, 12, 25))"🌕 full moon, 99% lit"Example results generated on 2026-11-04. Ones using now, today or randomness will differ when you run them.