public function getCurrentDuration() { $parts = json_decode($this->time_log) ?: []; $part = $parts[count($parts) - 1]; if (count($part) == 1 || !$part[1]) { return time() - $part[0]; } else { return 0; } }