Timestamps and conversion

Time is a very import function in programming. Its used a lot in databases records.
At first I could not find any way of producing these until I stumbled upon DEVICE and the block seconds since 1970 i.e. Unix time - perfect.
However, I’ve not yet found a way to convert these timestamps back to a human readable form.

Does anyone know if there is a way (I’d rather not call an external API)

Thought I would enquire before I make a request for enhancement

1 Like

If you look at the blocks from this category, you will see that there are other blocks for working with dates and time.

Like @actech stated there are blocks to grab current

Month, day of month, day of week, hour, minute, second, and year

Thanks, actech and jgibb20189

I can use these to create a timestamp in human readable form and in my current app will use as there appears to be no other option.
I’m from the old school and storing a character string like that is bad practice. A unix time, as given in the “time since 1970”, is a much better solution. Firstly its a much smaller entity to store and as its often already native and therefore faster for the cpu to process. What’s more its easier to sort records with a number.
Ugly as it is, I’m going to store both the human readable string and the Unix time. That way I can sort on the unix time and not have to write a very ugly procedure to be able sort on the character string.

I believe this product would benefit from much better time handling which should not be a difficult X platform process.
Hold the press!

The above I put together (sure it might be further refined) to produce a 8 character string which can be sorted upon. It could be further enhanced to include hour and second. Its easy to carve up back into a more normal date representation.

Note the Join is need to convert the numeric to a text string


If you need fast and reliable operation of Thunkable X, do not use app-variable blocks.

would you suggesting using the “stored” or “cloud” variable instead?

I suggest using variables from the function parameter and components that can be used to transfer data between screens (if necessary)

Hi @actech ! I just found the comment accidentally and I think this is very important. Could you please show by example what you mean or point out some posts if you already did.