Hi, just wondering what best practice is on the following.
In my app the ‘Date and Time’ successfully returns my local date and time.
But on the server side NOW returns a time that is 12 hours behind, I do not know why but presumably that is where my MySQL is hosted or where wappler server time is coming from.
To get an accurate local time into my data I could send a local time from the app to the server, but that seems a waste when NOW is sittng there waiting to be utilised.
NOW on the server side (in your server action) uses the time zone your server is set to.
NOW on the client side (on the page) uses the users local time.
Best for if you need to order your records in exact order they were entered in. Using it one client side will use the users computer time. So if someone on Eastern Time Zone enters something first and someone from Western time enters something and you sort by date and time it will not show in the same order it was entered.
I use client side for some things and server side for time ordering functions.
Hi teodor, one more question.
Obviously now, all time should be stored as UTC, but, later, to display the time on local time an offset has to be calculated.
In the app side, there is a function that seems tempting to help to be used to calculate the offset…
So i fed fhis into the dynamic attribute of a text input box , but teh result only gives me back the local time, am i missing something?
The first date is my local time, the second date has toUTCDAte() function applied, but both are the same as your can see. Last time i looked a I dont kive in greenwich, england.
It would be marvelous if wapplers rich function library could be enhanced with a toLocalTime() function that uses the local timezone calculated aganst a UTC datetime parameter.
Further to the above, when I was not watching, teh UTC time corrected itself
So are you saying the function converts the UTC time record from the database to local time on the front end, or is it just displaying local time on the input before submitting?
A function that did the conversion would be ideal without having to work out the difference, recording the hours and mins against the user and then use this to convert UTC to the correct local time.
As an X Bubble.io user this is one thing they had nailed early on and did really well, you didn’t need to think about it.
Time conversions on complex processes can send you batty and waste so much time getting your head around it.
It would be great if Wappler had a good automagical solution for this!