Skip to content

Instantly share code, notes, and snippets.

@Simounet
Created July 30, 2012 08:55
Show Gist options
  • Save Simounet/3205723 to your computer and use it in GitHub Desktop.
Save Simounet/3205723 to your computer and use it in GitHub Desktop.
mysql date comparison function
<?php
static function mysql_timediff( $datefield, $date_to_compare, $tbl, $cond_field, $cond_value ) {
$db = eZDB::instance();
$sql = "SELECT TIMEDIFF($datefield, $date_to_compare ) FROM $tbl WHERE $cond_field = '$cond_value';";
$rows = $db->arrayQuery( $sql );
return $rows[0];
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment