Data Connection is a high consuming energy feature on smart devices which is almost always on, even if the device is inactive. On HTC One M8 there is an option to automatically disable and turn off data connection at specific times to reduce the battery usage.
To turn off data connection on HTC One M8 do as follows:
1. Open Settings application and go to Power menu
2. Under Battery settings, open Sleep Mode and make sure it is enabled
3. If you mark the "Learn sleep time automatically" option, the phone estimates the inactivity periods and automatically turns off data connection
4. If you unmark the mentioned option, you can manually add the Sleep Time (Staring and Ending the sleep mode at them specific given time)