JasonJohnson
8 years agoQrew Assistant Captain
How can I use javascript to get current date/time to use as a variable in a formula
I have tried to find a way to put a javascript in as a variable to get the current date and time. It would have been great to use the native 'Now()' function but it only uses the time that the page last refreshed. The below code is what I hope to use once I can insert as a variable.
And honestly I am such a low coder that this will probably not work. The rest of my formula that I am planning to use works perfectly except for getting a current time variable that is accurate. Has anyone done this before or knows how to do this in a simple manner that even a low coder can manage it?
function timeNow(i) { var d = new Date(), h = (d.getHours()<10?'0':'') + d.getHours(), m = (d.getMinutes()<10?'0':'') + d.getMinutes(); i.value = h + ':' + m;
}And honestly I am such a low coder that this will probably not work. The rest of my formula that I am planning to use works perfectly except for getting a current time variable that is accurate. Has anyone done this before or knows how to do this in a simple manner that even a low coder can manage it?