How-to set Android device date/time programmatically

celoftis picture celoftis · Aug 17, 2011 · Viewed 29.7k times · Source

BACKGROUND

I am working on a project using the Wi-fi only version of the Samsung Galaxy tab (7"). On some of the devices we are seeing the date/time on the device getting reset (don't know why) to some date in the past (like 1/1/2000).

QUESTION(S)

How can I programmatically reset the device date/time? I'd prefer to use some adb shell command if possible (my shell scripting is rusty). If there is no shell command that can accomplish this, is there a way to accomplish this by writing and installing an app (seems like a security violation)?

Answer

JuanMa Cuevas picture JuanMa Cuevas · Apr 23, 2012

You can use the next command:

adb shell date -s YYYYMMDD.HHmmss

example:

adb shell date -s 20120423.130000

sets the date to Mon Apr 23 13:00:00 CEST 2012 (my phone is on CEST time zone)