Using the Shortcuts app (included on every iPhone running iOS 13 or higher) you can trigger an action at sunrise or sunset. This can come in handy for setting alarms, playing music, and other tasks. Here's how to set it up.

First, open the Shortcuts app. If you can't find the icon, swipe downward with one finger from the middle of the screen. Type "Shortcuts" in the search bar, and then tap "Shortcuts" when it appears.

Type "shortcuts" in Spotlight search then tap the Shortcuts icon.

Tap "Automation" at the bottom.

In Apple Shortcuts on iPhone, tap the Automation button at the bottom of the screen.

If you've previously set up automations on your iPhone, tap the plus sign (+), and then tap "Create Personal Automation." If this is the first automation you've ever created, tap "Create Personal Automation."

In Apple Shortcuts on iPhone, tap "Create Personal Automation"

On the "New Automation" menu, tap "Time of Day."

In iPhone Shortcuts, tap "Time of Day."

Here, you can select whether the automation will be triggered at "Sunrise" or "Sunset."

In iPhone Shortcuts, tap "Sunset."

On the next menu, you can select a time offset, such as "30 Minutes Before Sunset" or "At Sunset." The same applies to the sunrise options. Select your preferred option, and then tap "Done."

In iPhone Shortcuts, tap "At sunset."

After you've selected either "Sunrise" or "Sunset," if you want the action to repeat "Daily," "Weekly," or "Monthly," tap your preference. If you want an action to occur every day at sunrise or sunset, tap "Daily."

In iPhone Shortcuts, tap "Daily."

Tap "Next" to go to the "Actions" menu. This is where you define what you want to happen at sunrise or sunset. You can select any action available in shortcuts, including displaying an alert, setting a timer, starting an app, and more. You can also chain multiple actions together.

In our example, we'll set our action to start playing a song from our Apple Music Library.

An example of playing a song on the Automations Actions screen.

After you define your action(s), tap "Next." You'll see an overview of the entire automation. Tap any section here to go back and make changes.

Before you move forward, toggle-Off the "Ask Before Running" option. In the confirmation pop-up that appears, tap "Don't Ask." If this is enabled, your automation won't run unless you check your screen and confirm it first.

In the Automation overview, turn "Ask Before Running" off.

Tap "Done," and you'll see the automation you just created in your "Automation" list.

An iPhone automation in the automations list.

If you ever want to disable an automation, just tap it in the "Automation" list. In the next menu, toggle-Off the "Enable This Automation" option.

Tap "Enable This Automation" to turn it off.

You can return to the "Automation" section in the Shortcuts app at any time to enable an automation once again. If you ever want to completely delete an automation, just swipe left on it in the list, and then tap "Delete."

Happy automating!