Insert current time

Started by rahikumar, 05-10-2011, 03:03:32

Previous topic - Next topic

rahikumarTopic starter

Hello,

I wrote a script to insert the current time on a field depending on another field

for example if my field "start" = "Now" then my field "pick_start_time" should get the current time

what my script is doing when "start" = "Now" I get redirected to a blank page with the time on it
not sure how to get the time on my "pick_start_time" field

here is what I have so far

var tName = 'pick';
var ctrlkeycontrol = Runner.getControl(pageid, 'start');
var ctrlkeycontrol02 = Runner.getControl(pageid, 'stop');
var ctrlresp = Runner.getControl(pageid, 'pick_start_time');
var ctrlresp02 = Runner.getControl(pageid, 'pick_finish_time');
function func() {

var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
if (minutes < 10){
minutes = "0" + minutes
}
document.write(hours + ":" + minutes + " ")
if(hours > 11){
document.write("PM")
} else {
document.write("AM")
}
};
if (ctrlkeycontrol.getValue() == 'Now')
ctrlkeycontrol('==', func);


  •  


damponting44

A static value in a worksheet is one that doesn't change when the worksheet is recalculated or opened. When you press a key combination such as Ctrl+; to insert the current date in a cell, Excel "takes a snapshot" of the current date and then inserts the date in the cell. Because that cell's value doesn't change, it's considered static.


Lishmalinyjames

To insert the current time, press Ctrl+Shift+; (semi-colon). To insert the current date and time, press Ctrl+; (semi-colon), then press Space, and then press Ctrl+Shift+; (semi-colon).
=TODAY(): Current date (varies)
=NOW(): Current date and time (varies)