This topic is locked

Time button

8/14/2007 2:14:09 PM
PHPRunner General questions
F
fsteves author

Add this to include/jsfunctions.js

function getTime() {
var d = new Date();

var t_hour = d.getHours(); // Returns hours

var t_min = d.getMinutes(); // Returns minutes

var t_sec = d.getSeconds(); // Returns seconds
if (t_hour < 12){

t_ampm = "AM"

}
if (t_hour >= 13){

t_hour = (t_hour - 12)

t_ampm = "PM"

}
if (t_hour == 12){

t_ampm = "PM"

}
if (t_hour == 00){

t_ampm = "AM"

t_hour = 12

}

if (t_sec <= 9){

t_sec = "0" + t_sec

}

if (t_min <= 9){

t_min = "0" + t_min

}
return (t_hour + ":" + t_min + ":" + t_sec +" " + t_ampm);
}


And then call it with something like this added to the ADD or EDIT pages next to the input field:

<IMG style="CURSOR: hand" onclick="setTime(editform,'value_DepartureTime');" height=20 alt="Click Here to set the time." src="images/clock.gif" width=20 border=0>



If there is a better way to do it please let me know!

J
Jane 8/15/2007

Hi,
you can also add your JavaScript code to the C:/Program Files/PHPRunner 4.0/source/include/jsfunctions.php file. In this case you don't need to edit generated file after rebuilding.