Please Help Me With An Idiot's Guide to Converting UTC to Local Times

I’ve just spend half an hour reading posts about working with Local and UTC times in Wappler and I am just confused. Maybe I’m just being stupid and missing something obvious…

The Issue

My app is international. It stores the times when things happen. Hence I want to store the times in the database in UTC time, and display them in my app in the user’s local time.

Storing them in UTC time seems very easy. In my Database Insert action I just enter NOW_UTC in the appropriate field.

I would like to retrieve the UTC time from the database, and in my client side HTML just use some kind of function like .toLocalTime() to display them in the local time:

<p>{{query1.data.some_datetime.toLocalTime().formatDate('d MMM (h:mma)')}}</p>

Here are my questions:

  1. Does Wappler have this kind of function? If so, what is it?
  2. If not, should I work out my local time offset from two different datetime items set to local and UTC time and use that offset to do the conversion?
  3. If that isn’t possible, do I need to store the user’s local timezone in MySQL and do it from there? Will that need a stored procedure or something to work out the offset?

Please help me someone! :confused:

Community Page
Last updated: