If you want to listen to music on your iPhone for a set period of time, maybe because you need to go somewhere in 30 minutes or you're trying to fall asleep to music, the built-in clock app has a neat feature. You can set a timer to sleep your iPod once time runs out. It's really easy to do. Just open up the clock app, set the time you want, and then tap "When Timer Ends." If you scroll all the way down to the last option, past your ringtones, you'll see one called "Sleep iPod." Select that, start playing some music (or a podcast or whatever), and start the timer. When it ends, the music will fade out and stop.
Check out the video
‪How to Set a Sleep Timer on Your iPhone‬‏ - YouTube
Check out the video
‪How to Set a Sleep Timer on Your iPhone‬‏ - YouTube