Date picker submitting date one month early + time issue

Wappler Version : 3.9.7
Operating System : Windows 10
Server Model: Node.js
Database Type: MySQL
Hosting Type: Heroku

Expected behavior

I have an input in a form on my page, set to be a Date Picker with the “Time Picker” option checked.
Using the server connect form to insert into the database field (Type: Datetime) I would expect that if I put 07/05/2021 (DD-MM-YYYY) and 12:00 as the time, the database entry would reflect something similar

Actual behavior

Putting in those values like so:
image1

This is how it looks in the database:
image2

It’s most likely something silly I have done, but after checking over it again I can’t seem to figure it out!
Any help would be appreciated.

I forgot to include the code snippit!

image3

Hi @lighthouseit!

The way it is set in the database looks standard. What you can do when retrieving the data from the database is convert it into the format that you want to use.

As far as the data itself, I see two issues.

The first is that it appears to be a day off. You might look at where the server is located compared to where you are located to correct that. (As that is a server issue and not a wappler issue, you might have to code in a plus one day to resolve that issue.)

The second issue is regarding the time not being stored correctly. Have you checked in a third-party tool to ensure that the time is not being saved correctly? I had the same issue in Insert/Update Query updating datetime with same value

I do not see this as one day off but as 1 month off

Database format looks like yyyy-MM-dd HH:mm:ss
Your Wappler input is MM-dd-yyyy HH:mm:ss

So you have 2 problems here, 1 is that your datetime picker in Wappler is set to format as per your locale, so wherever you are, while your server database is in a more normal, or different locale format.
2. is that your time seems to be 12 hours off.

So you just chose the worst dates as well as times you could have for your testing, as the midday went 12 hours off and added a full day by turning to midnight, and your month and day are transposed.

Try test with a date that is out of range for the database to transpose, so try something like
20th May 2021 at 3:00 PM and I assume it is going to give an error inserting the record because it will try to use 20 as the month which is impossible.

Once you ascertain if that is in fact whats going wrong, then look at either your server mysql to see what timezone that is set to, and adjust if needed, else if that is correct, then adjust the Wappler picker to account for it.


Try mess with the Format and times UTC options to get it working as expected

If you dateformat to your user has to be displayed as MM-dd-yyyy HH:mm:ss and you have no control over your server, then you can also leave both as they are and adjust on the Wappler Database Insert/Update server action. with something like

{{$_POST.removaldate.formatDate('dd-MM-yyyy HH:mm:ss')}}

Keep in mind there are other formatters for date adjustment before the sql insert step like

.toUTCTime()
.toLocalTime()
.dateAdd('days', -5)
.formatDate('dd-MM-yyyy HH:mm:ss')