YouTube can now remind you to take a break. Losing track of time on YouTube is easy, but an optional feature can help you by reminding you to take a break.
YouTube: Remind me to take a break
Make sure you have the latest version of the YouTube app, then go to Settings> General. You should see the option "Remind me to take a break" you can choose intervals between 15 and 180 minutes.
It won't stop you from watching your videos on your phone all night instead of sleeping, but it will ask you to stop once in a while.