How to implement 24-hour limit using Amdoren Time API and TinyDB?

Hello everyone,

I am building a Kodular app and I need to restrict a CardView click to once every 24 hours. To prevent users from cheating by changing their phone time, I am using the Amdoren Time API to get the reliable current time.

The Problem:
I am getting the error: “Segment: Start is less than 1” and some math operation errors. I think I am not parsing the API response correctly, or perhaps my Clock timer is firing before the data is fully loaded.

Here are my blocks attached. Can anyone help me fix the parsing or the logic?

Thank you in advance!



blocks (18)

What’s the response are you getting?

1 Like

Segment: Start is less than 1 (0).

Is your url is correct?

To know the worldtime of your preferred location, url must be like this

https://www.amdoren.com/api/timezone.php?api_key=your_api_key&loc=New+York

Convert the response into json then using dictionary get the value of time

{
“error”: 0,
“error_message”: “-”,
“time”: “2026-02-23 01:00:45”,
“timezone”: “Eastern Standard Time”,
“offset”: -300,
“daylight_savings”: “No daylight savings”
}

When Web.GotText
Call JSONTextDecode with responseContent
Set variable “jsonDict” to result of JSONTextDecode
Set variable “timeValue” to Dictionary.GetValue(jsonDict, “time”)
Show “timeValue” in a label or do further processing

1 Like

1 Like

Hi dear,

I’m stepping in to add a few details regarding the error:

It indicates that you are segmenting a text by passing start = 0 as a parameter.
This is obviously an error, because you should start at least from 1. As a result, the portion of text you are trying to get with StartAtText has not found anything.

As pointed out by Still-learning, it would be better to format the response and use dictionary blocks to retrieve the value of the “time” key.

Edit:
I don’t know if you’re aware, but these APIs only allow 10 calls per month on the free plan.

Anyway try like this,

I used this URL as recommended by Still-learning.

https://www.amdoren.com/api/timezone.php?api_key=your_api_key&loc=New+York

I had to convert the date from yyyy-MM-dd hh:mm:ss to MM/dd/yyyy hh:mm:ss, which is why you see many blocks.
In the notifier, you receive the date in milliseconds.

2 Likes

Think if API fail to respond then??? If you want a permanent solution I can provide it to you. Contact on whatsapp if you need it.

1 Like

Thank you all for the amazing support and for teaching me about JSON and Dictionaries! It’s much clearer now why my segment blocks were failing.

Special thanks to you for pointing out the 10-call limit on Amdoren. I didn’t know it was that low! Since I’m just starting and don’t know if my app will be successful yet, I really need a completely free method to get the time reliably.
Could you please recommend a free alternative API (like WorldTimeAPI or similar) that works well with the JSON blocks you suggested? I want to make sure I’m using a stable and free source for my 24-hour logic.

thank you for the offer, but I prefer to keep the discussion here in the community so everyone can benefit from the solution. If you have a free method or suggestion, please feel free to share it here. Thanks again to everyone!"

2 Likes

:grin:

1 Like

I think you had already many ideas to get ontime with unlimited call uaing web get method in your old thread but still…

using utctime web url

1 Like

Many thanks to both of you for continuous help.
I want to try the two methods
@RaYzZz, could you please share the link for the KIO4_Terminal extension? so I can try it.
@Still-learning, I’m also going to try your utctime method as well.
I will update if I face any problem so you can help me.

Thanks again.

1 Like

Hey @Noor_XD
I saw your post and make a little extension for your help.
com.glich.onlinevalidation.aix (8.6 KB)
(I haven’t test it :sweat_smile: )

:puzzle_piece: How Users Will Use It in Kodular

:one: Drop extension
:two: On Screen Initialize → SetDurationHours(24)
:three: Call → CheckValidation

Then handle events:

  • OnValid → allow app
  • OnExpired → close or lock
  • OnTampered → block
  • OnInternetRequired → show message
Features (short)
  • :globe_with_meridians: Uses real internet time (Google server date header)
  • :locked_with_key: Anti-tamper detection (manual time change, rollback, timezone tricks)
  • :hourglass_not_done: Auto expiry from first launch (24h / 7d / 30d / custom hours)
  • :satellite_antenna: Works offline temporarily with forced periodic online check
  • :floppy_disk: Persistent storage — remembers state across app restarts
  • :high_voltage: Simple events: Valid, Expired, Tampered, InternetRequired
3 Likes

Here you go

curl -sI https://google.com | tr -d '\r' | grep -i '^Date:' | sed 's/^[^,]*, //' | awk '{m=$2; if(m=="Jan")m="01"; else if(m=="Feb")m="02"; else if(m=="Mar")m="03"; else if(m=="Apr")m="04"; else if(m=="May")m="05"; else if(m=="Jun")m="06"; else if(m=="Jul")m="07"; else if(m=="Aug")m="08"; else if(m=="Sep")m="09"; else if(m=="Oct")m="10"; else if(m=="Nov")m="11"; else if(m=="Dec")m="12"; print m"/"$1"/"$3" "$4}'
1 Like

Protip: search the extensions directory next time

Taifun

seems tough one or I am begginer?

Hi dear, what seems difficult to you?
If you have any doubts, feel free to ask.

1 Like

Nothing is difficult now, thank you so much for asking, I actually understood your method, and thanks a lot guys for all the help
@Glich, I just tested your extension and it’s perfect! It even caught me when I tried to change the phone time. Thanks a ton for making this for me
@RaYzZz, you know I always appreciate your help, you’ve been supporting me from the start. I’m gonna use the extension for now to save some time, but I’m definitely keeping your terminal method as a backup. It’s good to have a pro way like yours just in case. Thanks for being so helpful as always

3 Likes

Was referred to


Of course, I understand that it’s much more convenient.
Have a great day dear

1 Like