How to get automatic time setting on phone?

Hi everyone, I have a question. I’m building an application that displays time. I try to use online time from worldtimeapi.org, but sometimes it takes a while to get the clock. is there a way to know the time settings on the cellphone automatically or manually? or maybe there is a better solution than my block. Here are the blocks that I use. Thank you in advance.

[image]blocks (1)

use the clock component together with for example the Now and the FormatDateTime method
https://docs.kodular.io/components/sensors/clock/#format-date-time
see also App Inventor Code Snippets | Pura Vida Apps

Taifun

1 Like

Thanks for your suggestion, @Taifun. But I think its method for getting value from phones clock, right?

Yes, and it can be changed by user.
Here is something useful:

Oke @Kenin thanks, I’ll try :slightly_smiling_face:

1 Like

I used block as shown in the example, but it looks like it only fetches from phone time, not from the server. At my place should be 20:45 …

[image]


There’s a block
Get online date and time
image

You will get the response in GotOnlineDateTime block

2 Likes

Thaks @AtharvaPawar, its work… :innocent: :innocent: :innocent:

1 Like

Remember to add a condition:
If response is a number
Cause if it isnt a number then you will get an error due to slow network or no internet connection as response, and if you do get then use network component to check whether there’s internet or no, if yes then use GetOnlineDateTime block again and if theres no internet use a notifier to notify the user theres no internet connection.

1 Like

Oke @AtharvaPawar, thanks again… :innocent:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.