function cmfcCalendarV1::dateTimeDiff in Calendar Systems 5
Same name and namespace in other branches
- 8 calendar/v1/calendarV1.class.inc.php \cmfcCalendarV1::dateTimeDiff()
- 8.2 calendar/v1/calendarV1.class.inc.php \cmfcCalendarV1::dateTimeDiff()
- 6.3 calendar/v1/calendarV1.class.inc.php \cmfcCalendarV1::dateTimeDiff()
- 6 calendar/v1/calendarV1.class.inc.php \cmfcCalendarV1::dateTimeDiff()
- 7.3 calendar/v1/calendarV1.class.inc.php \cmfcCalendarV1::dateTimeDiff()
- 7 calendar/v1/calendarV1.class.inc.php \cmfcCalendarV1::dateTimeDiff()
- 7.2 calendar/v1/calendarV1.class.inc.php \cmfcCalendarV1::dateTimeDiff()
Date : 15-12-2003.
Ref: Dates go in "2003-12-31". Ref: Times go in "12:59:13". Ref: mktime(HOUR,MIN,SEC,MONTH,DAY,YEAR).
Splits the dates into parts, to be reformatted for mktime. $first_datetime = getdate($first_datetime); $second_datetime = getdate($second_datetime);
makes the dates and times into unix timestamps. $first_unix = mktime($first_datetime['hours'], $first_time_ex[1], $first_time_ex[2], $first_date_ex[1], $first_date_ex[2], $first_date_ex[0]); $second_unix = mktime($second_time_ex[0], $second_time_ex[1], $second_time_ex[2], $second_date_ex[1], $second_date_ex[2], $second_date_ex[0]); Gets the difference between the two unix timestamps.
1 call to cmfcCalendarV1::dateTimeDiff()
- cmfcCalendarV1::countDown in calendar/
v1/ calendarV1.class.inc.php - * For supporting timezone , use this class date and time functions like phpDate
1 method overrides cmfcCalendarV1::dateTimeDiff()
- cmfcCalendarV1Gregorian::dateTimeDiff in calendar/
v1/ calendarSystems/ gregorian.class.inc.php - Date : 15-12-2003.
File
- calendar/
v1/ calendarV1.class.inc.php, line 286
Class
Code
function dateTimeDiff($endTimestamp, $startTimestamp) {
$timediff = $endTimestamp - $startTimestamp;
// Works out the days, hours, mins and secs.
$daysTotal = floor($timediff / (24 * 60 * 60));
$remain = $timediff % (24 * 60 * 60);
$hours = floor($remain / (60 * 60));
$remain = $remain % (60 * 60);
$mins = floor($remain / 60);
$remain = $remain % 60;
$secs = $remain;
// Returns a pre-formatted string. Can be chagned to an array.
$result['daysTotal'] = $daysTotal;
//$result['days']=$days;
$result['hours'] = $hours;
$result['minutes'] = $mins;
$result['seconds'] = $secs;
return $result;
}