Hi,
the table contains a DateTime field and in most cases it is the time of record creation. To simplify data entry for users, I want to pre-fill this field for a new record. I used the following onLoad script:
const praveTed = new Date();
doo.model.datumACas.value = praveTed;
doo.toast.info(praveTed);
The field is inserted with a time one hour higher (+1) than the current time. But the info toast with the output of the same variable prints the correct current date and time (see attached screenshot).
Where is the error? How to write the correct time into the field using a script?
The application time zone is set to Europe/Prague.
THANKS, it works…
But why? I assume that the values are stored in the db in UTC and when displayed are adjusted according to the time zone set for the application. But when writing to the field using the script doo.model.datumACas.value = praveTed; is it necessary to use hard UTC time, but without the UTC zone designation (Z at the end)?
Do I understand this correctly?
I have a script that creates a duplicate record when saving one. One field is in datetime format. I’m using doo.table.createRecord function to duplicate. Date field is mapped like this:
“data”: doo.model.data.value,
I’ve used your formula to set the default datetime for today and displaying the date on the first record works properly
BUT
on the duplicate record the time displayed is 2 hours before.
I have console.log on this field set and in the both records it shows the same value inside:
may I just ask how you create duplication? Via WF client or server? Please try both options. In the new version of the application, the bug with the date in the counted field will be fixed (also 2h less). Feel free to send me part of the code so I can simulate it as best as possible.
There’s a bunch of problems with dates in tabidoo, specially with timezones.
For example, when I have the datetime field and in the script I put this:
doo.model.dateTimeField.setValue(new Date());
It shows the time on the form 2 hours later than it should. But when I put the field on the console.log() it shows the time properly. So the time itself is ok, but it’s showed wrong.
Then, when I use doo.model.createRecord to duplicate the datetime, the new record have the time shifted by 2 hours before.
It’s really compolicating things, specially when working on event management projects or financial, where time is necessesary and it should be precise
I understand that working with data is not the easiest and we are working on improving it and unifying the server/client time. Please take a look at our documentation, here are the features that take time out of the application locale.