Fun Share: Fun with Date Formatting

This project shows different ways of working with time/timestamps using the web viewer. Keep your time in seconds (as it really should be) and format it for the user only when needed! AND format in your preferred way! ON THE FLY!

https://x.thunkable.com/projectPage/61e8895b1943bc0010bf7b86

It allows you to use any formatting string available here

Skys the limit!

The basic idea here is to pass “seconds since 1970” values and a format to the webviewer and to receive back a formatted version of that time stamp.

Why’s this useful?
It’s important to know that “seconds since 1970” or a “time stamp” is how most computers think about time. And what’s more, they’re all in sync. What happens on the client side is that these timestamps are converted to a date string by some fancy algorithms that take into account the seconds value plus your local timezone.

You can do a lot once you don’t rely on being able to actually read the timestamp.

you can:
Compare 2 dates
add time to a date
find if 1 duration overlaps or is contained by another duration.
find durations of time between dates/times
and more!

3 Likes

While you’re in tutorial mode :stuck_out_tongue: I’d love to see a tutorial about how to use the Web Viewer with scripts. I always look at these examples and wonder what the actual html/javascript file is, how the person figured out how to make it, how it gets called from the Web Viewer, whether or not a personal server/back end is required, etc. I feel like I’m about 90% of the way there but just can’t quite put everything together in my mind.

Sounds like a good office hours topic. :wink: @domhnallohanlon what do you think?!

I’d love to hear from others in the community. Would others benefit from a demo of ways to use the web viewer message passing?

2 Likes

Sounds good to me @jared - we can definitely put together some examples/explainers on the extended web viewer!