# Simple calculation for difference between two times

**URL:** <https://forum.kirupa.com/t/simple-calculation-for-difference-between-two-times/329672>\
**Category:** flash\
**Created:** [September 30, 2012, 8:43pm UTC](https://forum.kirupa.com/t/simple-calculation-for-difference-between-two-times/329672 "2012-09-30T20:43:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![turtleawkward](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@turtleawkward](https://forum.kirupa.com/u/turtleawkward)\
**Post date:** [September 30, 2012, 8:43pm UTC](https://forum.kirupa.com/t/simple-calculation-for-difference-between-two-times/329672/1 "2012-09-30T20:43:54Z")

</div>

Hey, I need help with a really simple calculation between two different times.

Simple final time - intial time = difference between times.

I’m just starting out and having some real teething issues in working things out, all I get out is 0hours 0mins.

This is what I have:

function addTime (event:MouseEvent):void  
{  
var time1:Number;  
var time2:Number;  
var answer:int;

```
time1=Number(inputOne.text);
time2=Number(inputTwo.text);

answer=time2-time1;
inputThree.text = answer + 'Hours' + answer + 'Minutes';

```

}

myButton.addEventListener (MouseEvent.CLICK,addTime)

Thank you to anyone for any help, I just want to be able to get this working and wrap my head around it.
