How to get current time of the cellphone in which i am automating the application?

Hi,
I have a scenario in which I need to get the current time of cell phone in which I am automating my script. Is there any way to do it?

try, driver.getDeviceTime();

Hi @in-ishan ,
I tried driver.getDeviceTime();
but it is giving me an error: “That URL did not map to a valid JSONWP resource”.
This is not working for me. Someone, please provide me any other solution!

Hi Jitender,

I just tried, driver.getDeviceTime() on iOS Simulator and android device and it’s working. My driver object is Android / IOSDriver object

#Android
AppiumDriver driver = new AndroidDriver(service.getURL(), capabilities);
driver.getDeviceTime();
#iOS
AppiumDriver driver = new IOSDriver(service.getURL(), capabilities);
driver.getDeviceTime();

Could you please tell about your driver object?

Hi @in-ishan,

My driver object is:
AndroidDriver driver= new AndroidDriver (new URL(“http://127.0.0.1:4734/wd/hub/”), capabilities);
driver.getDeviceTime();

Do I need to make some changes?