Capsud
Capsud

Reputation: 609

Android: how to change the time in emulator?

I've noticed that the time in my emulator for android projects is wrong. Its one hour behind. How do I go about changing the time and can I do it in eclipse?

Upvotes: 6

Views: 22530

Answers (10)

arberg
arberg

Reputation: 4265

Set the time on the emulator via ADB:

Bash:

adb root
adb shell "date $(date +%m%d%H%M%G.%S)"
adb shell "am broadcast -a android.intent.action.TIME_SET"

Powershell:

$currentDate = Get-Date -Format "MMddHHmmyyyy.ss" # Android's preferred format
adb root
adb shell "date $currentDate"
adb shell "am broadcast -a android.intent.action.TIME_SET"

The am broadcast signal the clock to update in the status-bar, though its not needed according to my tests on emulator API-31.

The adb root lets following adb command execute with root-access, which is needed to set the date.

Thanks to RipTutorial

See also duplicate Stackoverflow with more info for special android-devices: Set date/time using ADB shell

Upvotes: 1

chichilatte
chichilatte

Reputation: 1818

The question was 9 years ago, but these days (on a mac at least) you just change your mac's time in the OSX System Preferences Date & Time pane and it's immediately mirrored in the Android emulator.

Upvotes: -1

Alex Accaci
Alex Accaci

Reputation: 39

If you want to change date & time, from running emulator window go to:

Apps -> Settings -> Date & Time -> Disable Automatic date & time -> Set date & Set time

If you want to change timezone, from running emulator window go to:

Apps -> Settings -> Date & Time -> Disable Automatic time zone -> Select time zone

Upvotes: 3

Manish
Manish

Reputation: 1125

Increase emulator date by some certain hours, Perfectly working Here i am increasing time by 4 hours.

adb root adb shell "date date +09190400"

Month & Date : 0919(mmdd) hours : 04

Upvotes: 1

Mark B
Mark B

Reputation: 200850

I believe the emulator is set to the GMT timezone by default. You can specify the timezone for the emulator with the -timezone parameter.

https://developer.android.com/studio/run/emulator-commandline.html

Upvotes: 3

trante
trante

Reputation: 34006

If you use IntelliJ you can do that from Run/Edit Configurations window. Go to Emulator tab and add this to "Additional command line options":

-timezone Europe/Helsinki

Android document gives this info:

-timezone Set the timezone for the emulated device to , instead of the host's timezone. must be specified in zoneinfo format. For example: "America/Los_Angeles" "Europe/Paris"

Zoneinfo format is also known as tz database. So to find you specific timezone, you can use the Wikipedia list here:
http://en.wikipedia.org/wiki/List_of_tz_database_time_zones

Upvotes: 1

manoj kumar gupta
manoj kumar gupta

Reputation: 39

use this command

C:\> adb shell

#date –- 2009-10-01 14:24:59

20070325.123456

#date –s 20070325.123456

Upvotes: 3

Jeff Hoye
Jeff Hoye

Reputation: 590

Run>Debug Configurations/Run Configurations

Tab Target> Additional Emulator Command Line Options

-timezone America/New_York

Upvotes: 6

Brie
Brie

Reputation: 2359

I have searched extensively, and it seems like the only option is to turn off the Auto-Set time in the emulator phone prefs, and manually set the timezone. I can't find any place to set emulator options from inside Eclipse/AVD Manager.

Upvotes: 0

user538565
user538565

Reputation: 513

refer to this page
http://ysl-paradise.blogspot.com/2008/09/android.html
in the comment part.

Upvotes: -1

Related Questions