Timestamp Column Converted to UTC In Wappler

As concerning as that is, its a valid way to work. And hence my suggestions about various ways to handle such scenario.

In our office, we update 2-3 days after release. We wait out a bit to see any big issues that might have snuck into the update. But we've made it a habit to stay on the latest version.

My habit has been to update within 20 minutes of the latest release being announced!

That said, I’ve not gone for v4.0.0 yet because I want to wait for today’s update to be absolutely sure all is well.

I’m not concerned at all...

I need stability, stability, stability, so it just feels very comfortable to me!

I scan all the bug posts, and upgrade on a Tuesday or Wednesday when a release feels particularly solid and if I fancy using some new feature that has come along...

I’m currently wondering what the best way is to handle this date issue with NodeJS. I created some Gantt planning schedule with a javascript library.

But when I add a database record with date “2022-01-01” (Type is Date on Postgress db):
date in db editor

on the front-end dmx.parse outputs “2021-12-31T23:00:00.000Z”:
datefrontend

This doesn’t make a whole lot of sense to me.

How do you guys handle such date/time difference issues?

The DB stored date is ok according to my timezone but during fetching it changes to UTC similar to this format “2021-12-31T23:00:00.000Z”
The solution:
During the wappler custom query in PostgreSql i have used

table.date::text

and its working perfectly.
If you have solved this issue in any other way please comment here.

I am working on my first NodeJS project. I’m converting a PHP project I just started so I figured why not. I already had a login code expiration query working in the PHP version so when I recreated my server connect php files in json the select query for the code expiration date kept returning a javascript Date object and I was banging my head against the wall until I found this post.

Thanks for this post, @sid

-Twitch

1 Like

Node uses the default date to json conversion, you can override the default behavior like:

Date.prototype.toJSON = function() {
  const date = new Date(this);
  date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
  return date.toISOString().slice(0, -1).replace('T', ' ');
}

Where should this be added?

I think easiest is to place it directly in the index.js before the server.start().

Could probably make an option for it in Server Connect where you choose how datetime should be returned from server actions.

That would be great. In our existing projects, maybe we will be able to simplify bindings with the help of this.

With the next update you will have an option to set the output format of datetime fields from the database, you can set it to a local or utc string.

1 Like

This has been improved in Wappler 5.2.2
We’ve added a few options to handle the date & time for NodeJS. Please check:

This topic was automatically closed after 47 hours. New replies are no longer allowed.