-2

i am building a small application to calculate employee attendance.

A user will check in, his check in time will be recorded in a mysql datetime format, for example

check_in_time 2011-12-16 20:27:20

And when he checks out

check_out_time 2011-12-16 20:27:27

I can do it the conventional way by exploding and doing the subtraction, but am sure Zend_Date has a more efficient way of doing it.

zf.
  • 123
  • 1
  • 1
  • 10

1 Answers1

0

Obviously my question was not hard to answer, anyhow this is the answer to get the time diff in seconds, then i can handle seconds normally.

Thanks for the docs @ajreal, i did not look correctly into them.

public function getTimeInSeconds($dateStart, $dateEnd) {
    $dateStart = new Zend_Date($dateStart);
    $dateEnd = new Zend_Date($dateEnd);
    $new = $dateStart->sub($dateEnd);
    $timeInSeconds = $new->getTimestamp();
    return $timeInSeconds;
}
zf.
  • 123
  • 1
  • 1
  • 10