Date/Time from server

Questions related to using nuBuilder Forte.

Date/Time from server

Postby marc » Thu May 07, 2020 2:32 pm

There is a button, when clicked, the current date/time is written into a field. So far so good. My problem is now if a user has their computer clock off the wrong date/time is saved to the db.
I'm wondering if there's some way get the date/time form the server instead from the local clock?

[code]function dateTimeNow() { // e.g. "2020-05-07 20:01:46"

var date = new Date();
var aaaa = date.getFullYear();
var gg = date.getDate();
var mm = (date.getMonth() + 1);

if (gg < 10)
gg = "0" + gg;

if (mm < 10)
mm = "0" + mm;

var cur_day = aaaa + "-" + mm + "-" + gg;

var hours = date.getHours()
var minutes = date.getMinutes()
var seconds = date.getSeconds();

if (hours < 10)
hours = "0" + hours;

if (minutes < 10)
minutes = "0" + minutes;

if (seconds < 10)
seconds = "0" + seconds;

return cur_day + " " + hours + ":" + minutes + ":" + seconds;

}
marc
 
Posts: 88
Joined: Mon May 14, 2018 10:56 pm

Re: Date/Time from server

Postby kev1n » Sun May 17, 2020 5:29 pm

Hi marc,

Run a PHP procedure with nuRunPHPHidden() that retrieves the time from the SQL Server.

See this topic:
viewtopic.php?f=6&t=7841&p=9842&hilit=nurunquery+now+time#p9842

use nuJavascriptCallback to pass the time to the client.
kev1n
 
Posts: 728
Joined: Mon Oct 15, 2018 2:13 am


Return to General