Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

How to automatically get correct time/clock

Questions related to using nuBuilder Forte.
ingar
Posts: 10
Joined: Mon May 06, 2019 9:31 am

How to automatically get correct time/clock

Unread post 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:

Image
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

Re: How to automatically get correct time/clock

Unread post 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
Last edited by Janusz on Mon May 20, 2019 8:56 pm, edited 1 time in total.
If you like nuBuilder, please leave a review on SourceForge
ingar
Posts: 10
Joined: Mon May 06, 2019 9:31 am

Re: How to automatically get correct time/clock

Unread post 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:

Image

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...
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 447 times
Contact:

Re: How to automatically get correct time/clock

Unread post 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
You do not have the required permissions to view the files attached to this post.
ingar
Posts: 10
Joined: Mon May 06, 2019 9:31 am

Re: How to automatically get correct time/clock

Unread post by ingar »

Hi again,

The sql-query gave this result:

Image

So it seems that the server's time is correct. Can't see what I've overlooked :o
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

Re: How to automatically get correct time/clock

Unread post 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.
If you like nuBuilder, please leave a review on SourceForge
ingar
Posts: 10
Joined: Mon May 06, 2019 9:31 am

Re: How to automatically get correct time/clock

Unread post 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:

Image

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.
ingar
Posts: 10
Joined: Mon May 06, 2019 9:31 am

Re: How to automatically get correct time/clock

Unread post by ingar »

I found out something... The column in the subform ('tidspunkt' = date & time) was set as nuDate Input type:

Image

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.
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: How to automatically get correct time/clock

Unread post by admin »

ingar,

You need to use nn for minutes (mm is months)


Steven
ingar
Posts: 10
Joined: Mon May 06, 2019 9:31 am

Re: How to automatically get correct time/clock

Unread post by ingar »

:oops: :oops: :oops: I totally misunderstood the "mm", thinking it was "minutes"... My head was under my arm in this case :oops: 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
Post Reply