Rise and shine! Need to set an iPhone alarm that goes off automatically every day at sunrise or sunset? Using Shortcuts on iPhones running iOS 13 or later, it's possible to create an automation that does just that. Here's how to set it up.

First, you'll need to locate and open Shortcuts. If you can't find it, swipe downward in the middle of your screen with one finger. When a search bar appears, type "Shortcuts," then tap the Shortcuts app icon that appears.

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

In Shortcuts, tap "Automation" in the menu at the bottom of the screen.

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

If you've made an automation before, tap the plus (+) button, then select "Create Personal Automation." If you haven't used automations before, just tap "Create Personal Automation."

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

On the "New Automation" screen, we're going to set up what conditions will trigger the automation. In this case, since we'll be setting an alarm for sunrise or sunset, tap "Time of Day."

In iPhone Shortcuts, tap "Time of Day."

In the list that appears, tap "Sunrise" or "Sunset." In our example, we will choose "Sunset."

In iPhone Shortcuts, tap "Sunset."

After tapping sunrise or sunset, you'll see a new screen that allows you to choose a time offset, such as "30 minutes before sunset" or "15 minutes after sunset." In our example, we're aiming for close to sunset exactly, so we'll pick "At sunset." Tap "Done" when you're finished.

In iPhone Shortcuts, tap "At sunset."

Next, decide whether you want your alarm to repeat daily, weekly, or monthly and tap the matching selection so that it has a checkmark beside it.

In iPhone Shortcuts, tap "Daily."

Then tap "Next," and you'll get to the Actions screen. This is where you define what you want to happen at sunrise or sunset.

Ideally, it would be perfect if we could use a system-wide iPhone alarm like the one you would set in the Clock app. It is possible to create a traditional Clock app alarm for a certain time using Shortcuts, but if you use that function, you'll need to dramatically increase the complexity of your automation. One reason for this is that every time your automation runs, another alarm will be created, and your Clock app will fill up with alarms quickly. We don't want that.

Related: The Two Quickest Ways to Set an Alarm on iPhone or iPad

So instead, we found a nice workaround using the Timer function, which will break through the iPhone's silent and do-not-disturb modes just like a regular alarm would. Other notification options in Shortcuts are typically silenced if your volume is turned down or your ringer is off. This method will make sure that you always hear the alarm as long as the iPhone is powered up and the automation is active.

So on the "Actions" screen, tap the "Add Action" button.

In Apple Shortcuts on iPhone, tap "Add Action."

A panel will pop-up. Tap the search bar and type "timer," then scroll down and tap "Start Timer."

Search for "Timer," then tap "Start Timer."

Once you see the "Start timer for" action on the screen, tap its properties and set it to 1 second. The idea is that once triggered by sunrise or sunset, a timer for 1 second will count down and ring.

Next, we'll add a message that tells you what this alarm is for. Tap the big plus (+) button located right below the timer action.

Set the timer to "1 second" then tap the plus button.

When a panel pops up, search for "notification," then scroll down and select "Show notification" from the list.

Search for "Notification" and tap "Show Notification."

When the action is added to your automation, tap the "Hello World" field and add a label that describes what the alarm is for. In our case, our official How-To Geek chickens get eaten after dark if we don't close the chicken coop, so we wrote "Close Chicken Coop at Sunset" as a reminder.

Modify the notification message.

There are other ways to display messages in Shortcuts (such as the "Alert" function), but the nice thing about using a notification is that it will show up on your notifications screen later as a record of what happened. It also creates its own audible and vibratory alarm, so if you'd like to use this instead of the timer method, you can erase the "Start timer" section. The main drawback of relying solely on a notification is that it can be silenced by certain settings on your iPhone, so you may miss the alarm.

When you're ready, tap "Next," then you'll see an overview of the automation. Near the bottom of the screen, flip the switch that says "Ask Before Running" to "Off." If you leave that enabled, your automation won't work unless you open your iPhone and tap a confirmation message first.

Tap "Ask Before Running" to turn it "Off."

Then tap "Done," and your Automation will be set.

In practice, you may find that your iPhone's idea of sunrise or sunset might not match your own (There's also dawn, dusk, and twilight to consider, for example, plus elevation and other factors.). So if you ever need to modify the automation, return to your Automation list in Shortcuts and tap the automation in the list, where you can adjust the sunrise or sunset offset or change the length of the timer to match your needs.

Also, if you ever need to disable the sunrise or sunset alarm, tap the automation in Shortcuts and flip the "Enable This Automation" switch to "Off."

Tap "Enable This Automation" to turn it off.

When you're done, you can ride off into the sunset in style---at exactly the correct time every day! Have fun.