Calling a javascript function
Posted: Fri Oct 29, 2004 2:53 pm
I need to calculate the current time and I want the current time from the user's computer not my server so I'm using javascript to calculate the time. The original place I'm using the function I have a button that the user clicks to get the current time for start time. That all works fine but now I want to get the end time and update my database with it. Here is the function
For the end time I want to have a variable that the end time is assigned to. So my question is how do I call the javascript function and assign it to a variable. I tried $endTime = getEndTime(); but that didn't work.
Code: Select all
<script language="javascript">
function getEndTime(){
var now = new Date();
var hours = (now.getHours()+17)-24;
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var endCall = "" + ((hours >12) ? hours -12 :hours)
if (endCall == "0") timeValue = 12;
endCall += ((minutes < 10) ? ":0" : ":") + minutes
endCall += ((seconds < 10) ? ":0" : ":") + seconds
endCall += (hours >= 12) ? " P.M." : " A.M."
return endCall;
}
</script>