Wappler Version : 3.4.0 (but happened in previous version too)
Operating System : Win10, NodeJS / Docker project
Expected behavior
When you convert a date or time to UTC or Other format options on the server action side, it should convert to the chosen format
Actual behavior
What actually happens?
It does not convert the date/time and the server action (a database update in this case) fails.
Error message:
{status: "500",…}
message: "Parser Error: Formatter "toUTCTime" does not exist, expression {{$_POST.start.toUTCTime()}}"
stack: "Error: Parser Error: Formatter "toUTCTime" does not exist, expression {{$_POST.start.toUTCTime()}}↵ at /opt/node_app/lib/core/parser.js:694:27↵ at /opt/node_app/lib/core/parser.js:661:25↵ at parser (/opt/node_app/lib/core/parser.js:352:19)↵ at parseValue (/opt/node_app/lib/core/parser.js:725:24)↵ at parseValue (/opt/node_app/lib/core/parser.js:716:26)↵ at parseValue (/opt/node_app/lib/core/parser.js:716:26)↵ at Object.parseValue (/opt/node_app/lib/core/parser.js:716:26)↵ at App.parseSQL (/opt/node_app/lib/core/app.js:348:23)↵ at App.update (/opt/node_app/lib/modules/dbupdater.js:38:26)↵ at App._exec (/opt/node_app/lib/core/app.js:255:57)"
status: "500"
This is an image of the server action step. Its a simple UPDATE. The START and END fields in this case are TIME inputs. I have also tried with date, datetime and also the DMX date/time picker inputs. Anytime the formatter is used it fails and throws the above error
The formatters are not missing and seem to work for me.
Do you have only problems with the date specific formatters? Please check the lib/formatters folder if the file date.js exists. Open the file and check if the methods toLocalTime and toUTCTime in it.
I believe Wappler only updates files depending on the file date, the date.js is from 22/07/2020. Not sure why your file is from 26/07/2020, but that is probably the cause that it wasn’t updated. I’m not sure if new files are copied again when you remove the lib folder, perhaps @George knows that.
Thanks @patrick. I’ll update this tomorrow morning. Would there be any chance the other formatters are missing functions or hadn’t been updated? Any way of telling without waiting untill something doesn’t work?
Try to rename the lib folder and then start Wappler with that project and see if it recreates the lib folder, it should then have all the latest versions.
The topic is about NodeJS server model, while your error is showing PHP files, which means you are using PHP server model.
Probably you have a different issue. Please explain where exactly are you trying to use this formatter when this error appears.
For what it’s worth, I find it more flexible to store all datetimes in the db as UTC, and then format to timezone on the front end (since that is where the time zone is determined). This allows for people to set their time zone, as well as move across different time zones, and just adds some consistency to things across the datetime coding world.
Makes perfect sense and is a better more consistent approach.
This however beckons the question of how to show local time on the front end. I don’t see any functions to convert datetime to local datetime. I could subtract the hours to arrive at my result, however employing a local time function would be ideal.
I am recording a user’s note on a record with a timestamp (auto generated by the DB).
Similar to how this forum records your statement from 2 minutes ago. Except, my use case is more simple in that I just want to show the timestamp at which the user made their comment.
So user Teodor said “abc” at 4:22 pm (local time). Right now, the datetime value is stored in UTC. So I just want to show the datetime timestamp in local time.