/** * Escapes a timestamp for use in SQL, includes surrounding quotes * * A `NULL` or invalid value will be returned as `'NULL'` * * @param string $value The timestamp to escape * @return string The escaped timestamp */ private function escapeTimestamp($value) { if ($value === NULL) { return 'NULL'; } try { $value = new fTimestamp($value); return "'" . $value->format('Y-m-d H:i:s') . "'"; } catch (fValidationException $e) { return 'NULL'; } }
public function getElapsedRatio() { $st = $this->getStartDatetime()->format('U'); $et = $this->getEndDatetime()->format('U'); $ts = new fTimestamp(); $now = min($ts->format('U'), $et); return max(round(100 * ($now - $st + 1) / ($et - $st + 1)), 0); }