Page 1 of 2
How to automatically get correct time/clock
Posted: Mon May 20, 2019 1:49 pm
by ingar
Hello everybody,
Since my first post a couple weeks ago, my database crashed completely (mysql-database) ... so, I had to start all over again with my little project.
I'm making a small customer phone-call logging system (when a customer calls, I'm recording data about what the call was all about).
In my subform, I have a need for an automatic value for
correct time of my registration of the call. I'm talking about the clock-time "right now" (as when I'm actually saving the record/row).
I have tried using
default value "CURRENT_TIMESTAMP" in phpMyadmin for this date-column ... but this clock timestamp always lags behind with somewhere 20 - 30 minutes (wrong time).
Is it possible to have an automatic "fill-in" of current realtime clock in my field named "tidspunkt" (='time') ... and ONLY doing so when it's a NEW ROW (new record) in my subform?
I've tried screaming at the application and hammering on the keyboard ....it didn't do any good
Here's an image of my form with the subform, and tablestructure of the phonelog:

Re: How to automatically get correct time/clock
Posted: Mon May 20, 2019 8:06 pm
by Janusz
Hi,
You can use timestamp.
As example please find enclosed a screen shot from my table.
https://drive.google.com/open?id=1_aEgM ... 8UFxopm2hw
Generally I use 4 fields for tracking every record - 2 for creation (name and date) and the same for update.
Date is fully managed by database and names are sent by nuBuilder.
This works very well without any delay with very good time precision:
https://drive.google.com/open?id=118bx5 ... JmtImKn30i
Additionally I checked with the subform - and works fine with no issuse.
Maybe someone is entering data to the subform and not pressing the save button just after but wating some time - date is updated after save operation.
For example you can add small save button as in attached example:
https://drive.google.com/open?id=1mnd2w ... lIGHS1PCIh
Re: How to automatically get correct time/clock
Posted: Tue May 21, 2019 8:53 am
by ingar
Thank you for your kind help and tips... I altered the field (column) as shown in your example. I only need the timestamp of when the call was made.
Or to be more precise: when the phonecall log info was entered and saved the first time.
But still ... the TIME (hour:minute) is still OFF with 15 - 30 minutes compared with the actual time I edited and saved a new record.
Editing and saving a new record takes only about 1-6 minutes most of the times. See the image below of what happened when i tried after the change of table in phpMyadmin:
After this example shown above ...
I did a new entry in the subform at the actual clock time 08:39 ... but after SAVING, it shows the time "08:05". And the time spent from searching the customer, opening the customer details form, talking with the customer, and finally entering into the subform (phonecall log) ..it took only about 5-6 minutes.
So ... there's definitely something I don't understand about this...
Re: How to automatically get correct time/clock
Posted: Tue May 21, 2019 8:58 am
by kev1n
Hi, could it be that the time on the server is off by x minutes?
You can easily test it by running this query:
select_now.png
Re: How to automatically get correct time/clock
Posted: Tue May 21, 2019 9:11 am
by ingar
Hi again,
The sql-query gave this result:
So it seems that the server's time is correct. Can't see what I've overlooked

Re: How to automatically get correct time/clock
Posted: Tue May 21, 2019 9:31 am
by Janusz
you can try add a row with phpmyadmin (to the suborm table directly) to see if the time is properly entered by database itself.
Re: How to automatically get correct time/clock
Posted: Tue May 21, 2019 3:11 pm
by ingar
Ok,
Now I tried to add a row directly into the table (subform), and got same result as shown below. I don
t know:
So .. could it be a problem with the server, which is running on the same computer I'm working on?
It runs only as a "localhost", and the screenshots of the Windows clock is from the same computer/server.
Re: How to automatically get correct time/clock
Posted: Tue May 21, 2019 9:33 pm
by ingar
I found out something... The column in the subform ('tidspunkt' = date & time) was set as
nuDate Input type:
And this formatting is causing this situation as it SHOWS the time different than the timevalue it's actually stored as in the table. When I set the Input type to "Text" - it shows the time correctly. Sorry, my lack of knowledge led me to use nuDate as Input type.
NOW with Input type "Text", it sadly enough shows the date the wrong (for me) way. It shows the date in this format "YYYY-mm-dd" ... would need it in this format instead: "dd-mm-yy", but can't find a way to do it.
Re: How to automatically get correct time/clock
Posted: Tue May 21, 2019 11:11 pm
by admin
ingar,
You need to use nn for minutes (mm is months)
Steven
Re: How to automatically get correct time/clock
Posted: Wed May 22, 2019 7:59 am
by ingar

I totally misunderstood the "mm", thinking it was "minutes"... My head was under my arm in this case

Sorry.... now I'm gonna dig a hole in the ground...
Thank you Steven for your kind help ... and thank you all that did such an effort trying to help me out!
-Ingar