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?

3 Answers 3

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?

1
  • I thought that adb shell uses root by default ><
    – janot
    Aug 11, 2014 at 10:20
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
1

Issue the following commands:

adb shell date -s YYYYMMDD.HHmmss

or

$ adb shell 
$ adb root
# su 
# date -s YYYYMMDD.HHmmss
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .