Fun Share: Yet another unix time converter in pure thunkable, no JS, no API

i want to share this one single block of thunkable code that does one thing only: convert a unix time (in seconds since 1970) into a readable date. for example 1655438752 would convert to 2022-06-16 21:05:52 PDT .

you call the routine as shown below:
image

i live in california which is offset from GMT by -7 hours, hence i can customize the converter to give results in local time.

here’s the project link:
https://x.thunkable.com/projects/62aac2ce515709001159e82b/067820fa-0b2d-4603-98dd-216da93513ef/designer

2 Likes

This is super cool

Does this account for leap years and daylight savings time? A timezone is different than an offset.

Leap years, yes. However DST and time zone logic seem difficult to do. Maybe there’s an api you can call at start that returns GMT offset and time zone at your current location. Maybe it can return the human readable date at the same time! Haha!

2 Likes

JS has the function. All what is required is a simple Thunkable block that accepts JS code. That’s it. Tons of issues will get resolved by such block

1 Like

didn’t you already make this block? you shared this project a couple of months ago.
https://x.thunkable.com/projects/621c9b6c73ba2500119d10ef/0b91a355-8bd1-4c25-972e-6f8874c63a7b/designer

you just construct your javascript code and pass it to the webserver for execution.
(i think you do need a webserver that will execute the script)

you should make a mini-tutorial showing how to use it, with a couple of examples , showing the actual javascript code that needs to be passed , the input and the outcome. we could have a snippet library submitted by the community that contains a collection of js code segments that can do many basic things best serviced by javascript.

1 Like

Yes, but that requires the web viewer which has its own problems like inability to run as local/packaged code.

The idea is for Thunkable to create a block or component that you can pass a JavaScript function and get the response in a way similar to API block but instead of passing a URL you just pass a JavaScript function.

This way we do not need to include the web viewer component and Thunkable would have lots and lots of generic functions in the JavaScript engine which solves lots of issues not only date related but many others.

2 Likes