4

I've tried

date -u 1407697765

output:

time 1407697765 -> 1407697765.0
settimeofday failed Bad file number

and

busybox date -s @1407697765

output:

date: can't set date: Operation not permitted

I don't feel that I'm doing everything right (especially when date -u) but it looks like I have no permission... I'm trying it through adb shell

Why do I get these errors and how to set date through shell?

janot
  • 555
  • 3
  • 9
  • 25

3 Answers3

2

The following worked for me (once you have root permissions):

adb shell settings put global auto_time 0 && adb shell date 010219302018.00 set && adb shell am broadcast -a android.intent.action.TIME_SET

auto_time -> This is to switch off automatic syncing of time.

To reset the time back to syncing with the network, do:

adb shell settings put global auto_time 1 && adb shell am broadcast -a android.intent.action.TIME_SET
iBug
  • 7,747
  • 8
  • 44
  • 83
1

Issue the following commands:

adb shell date -s YYYYMMDD.HHmmss

or

$ adb shell 
$ adb root
# su 
# date -s YYYYMMDD.HHmmss
Firelord
  • 25,084
  • 20
  • 124
  • 286
drover
  • 11
  • 1
1

Only the root user can set the date. If your phone is already rooted, just type suEnter to get into a root shell, then the command you want to run.

If your phone is not already rooted, you'll need to get root access first. See How do I root my Android device?

Dan Hulme
  • 35,000
  • 17
  • 90
  • 155