Click to See Complete Forum and Search --> : Time Difference


Edeline
11-12-2003, 10:05 PM
Dear all,

I am new in javascript.

I would like to compare A time with B time. But i don't know how to do in Javascript.
Does anyone have done the time difference javascript before?

Please kindly provide me the script.

Thans,
Edeline

pyro
11-12-2003, 10:32 PM
What format are your times in?

Edeline
11-13-2003, 12:41 AM
In hh:mm:ss

Charles
11-13-2003, 05:11 AM
<script type="text/javascript">
<!--
function Time (s) {var a = s.split(':'); this.date = new Date(1970, 0, 0, a[0] ? a[0] : 0, a[1] ? a[1] : 0, a[2] ? a[2] : 0)}

Time.prototype.valueOf = function () {return this.date.getTime()}

Time.prototype.toString = function () {return this.date.toTimeString()}

alert(new Time ('4:55') - new Time ('4:00'))
// -->
</script>