Can I play my music on the iOS Music app with a sleep timer? Maybe I’m going crazy, but I'm sure that I could listen to music on my old iPhone 4 and set the Music app to play to a sleep timer. So, if I wanted, I could play music for 30 minutes when I went to bed and it would automatically stop playing after 30 minutes.

I've now got a new iPhone and cannot for the life of me work out how to do this?

Did I imagine being able to do this on my iPhone 4, or was I just using another music app to do it?
I can't tell you what app you were using on your iPhone 4, but I can tell you how you can still play music on your new iPhone using a sleep timer. 

To do what you want, follow this process:


Launch the Clock app
Tap on the Timer option at bottom right
Set the timer to 30 min
Tap on the When Timer Ends option
Now swipe up until you see the Stop Playing option at the very bottom and select it
Tap on Set at top right


Now you can use the Music app (and most 3rd party music apps as well) to listen to your music and your iPhone will stop playing it 30 minutes later.

[EDIT]

So, the reason for your confusion (understandably so in my opinion), is that Apple’s implementation of this is OS wide, not as a specific function of the Music app. 

The advantage of this is you can use the feature with 3rd party apps like Spotify, but IMHO it would have also been good to have the option within the Music app itself. If you feel that way too, you can submit feedback to Apple.