+ /**
+ * Approximate time-comparison. $a and $b are considered equal if they
+ * are within $threshold seconds of each other.
+ *
+ * @param string $a
+ * Time which can be parsed by strtotime.
+ * @param string $b
+ * Time which can be parsed by strtotime.
+ * @param int $threshold
+ * Maximum allowed difference (in seconds).
+ * @return bool
+ */
+ public static function isEqual($a, $b, $threshold = 0) {
+ $diff = strtotime($b) - strtotime($a);
+ return (abs($diff) <= $threshold);
+ }
+
+}