Skip to content

Instantly share code, notes, and snippets.

@ryanmerritt
Forked from philsturgeon/gist:3228471
Created September 18, 2012 20:53
Show Gist options
  • Save ryanmerritt/3745827 to your computer and use it in GitHub Desktop.
Save ryanmerritt/3745827 to your computer and use it in GitHub Desktop.
Complicated Compare date difference (Seconds)
<?php
function calculateDateDiff($strStart, $strEnd) {
$parts = explode(' ', $strStart);
$dates = explode('/', $parts[0]);
$times = explode(':', $parts[1]);
$unix_start = mktime($times[0], $times[1], $times[2], $dates[0], $dates[1], $dates[2]);
$parts = explode(' ', $strEnd);
$dates = explode('/', $parts[0]);
$times = explode(':', $parts[1]);
$unix_end = mktime($times[0], $times[1], $times[2], $dates[0], $dates[1], $dates[2]);
return ($unix_end - $unix_start);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment