What is the time storing unit. Is it unix time stamp?

Try this.
Code:
$beginTimeConverted=strtotime($beginTime);
$endTimeConverted=strtotime($endTime);

// perform subtraction
$timeDiff=$endTimeConverted-$beginTimeConverted;