One of the power saving options on the HTC One M8 (and M9) is the Sleep Mode which turns off the mobile data either at given time intervals or automatically by learning your sleep time.
To enable Sleep Mode on HTC One M8, do as follows:
1. Go to the Settings application
2. Tap the Power option under the Phone settings
3. Scroll all the way down, find the Sleep mode option and slide the toggle button to enable the feature
4. To specify when the device should go to the sleep mode and disconnect data connection, tap the Sleep mode option, and either mark the learn sleep time automatically option, or simply specify the Start and End time