Display Sunrise and Sunset time in Unity UI

Hi.
I’ve been working in a star app recently and in one of the main menu of the app I want to show the specific time of sunrise and sunset of that specific day when using the app. Only the time, of course of the area that person may be using the app.
What should I do to display the time? What do I need?

Thanks

You probably need localization and local device time.
GPS data may help.

Other than that, I don’t think this question fits to General Forum.

1 Like

You’d need some service or data set which has that information for various locations, then you’d need their GPS coordinates. Lastly you’d correlate their GPS location to whatever location format is used in the service or data set if the data isn’t somehow already indexed by GPS coordinates. The first thing I’d do is find the data set to figure out what the next specific step is.

1 Like

Given that the Earth revolves around the Sun in a more or less fixed pattern, you probably should take a look at this:
https://en.wikipedia.org/wiki/Sunrise_equation

Basically, you’d need their GPS data (Latitude, Longitude and elevation), and exact date.

Also see:
https://docs.unity3d.com/ScriptReference/LocationService.html
and System.DateTime.Now (or UtcNow)

3 Likes