{"record":{"id":"fb42cbf5efe5921a","repo":"phacility/phabricator","slug":"unable-to-parse-time-s","errorCode":null,"errorMessage":"Unable to parse time \"%s\".","messagePattern":"Unable to parse time \"(.+?)\"\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/infrastructure/management/PhabricatorManagementWorkflow.php","lineNumber":23,"sourceCode":"  public function isExecutable() {\n    return true;\n  }\n\n  public function getViewer() {\n    // Some day, we might provide a more general viewer mechanism to scripts.\n    // For now, workflows can call this method for convenience and future\n    // flexibility.\n    return PhabricatorUser::getOmnipotentUser();\n  }\n\n  protected function parseTimeArgument($time) {\n    if (!strlen($time)) {\n      return null;\n    }\n\n    $epoch = strtotime($time);\n    if ($epoch <= 0) {\n      throw new PhutilArgumentUsageException(\n        pht('Unable to parse time \"%s\".', $time));\n    }\n    return $epoch;\n  }\n\n  protected function newContentSource() {\n    return PhabricatorContentSource::newForSource(\n      PhabricatorConsoleContentSource::SOURCECONST);\n  }\n\n  protected function logInfo($label, $message) {\n    $this->logRaw(\n      tsprintf(\n        \"**<bg:blue> %s </bg>** %s\\n\",\n        $label,\n        $message));\n  }\n","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/management/PhabricatorManagementWorkflow.php#L5-L41","documentation":"A PhutilArgumentUsageException from PhabricatorManagementWorkflow::parseTimeArgument(), the shared helper management workflows use for time options like --since. An empty value returns null, but any non-empty value that strtotime() fails to parse (or that resolves to an epoch <= 0, i.e. on or before 1970-01-01) throws.","triggerScenarios":"Passing a relative date with a typo (e.g. 'yesteday'), a locale-specific format strtotime() does not understand (e.g. '01/02/2025' ambiguity, '2025-13-45'), or a date before the Unix epoch; passing the literal string '0' or 'false' which strtotime maps to epoch 0.","commonSituations":"Shell scripts interpolating empty or malformed variables into --since/--until options; automation passing ISO dates with a 'Z' suffix on old strtotime() behavior; users typing natural-language dates the parser rejects.","solutions":["Use an unambiguous machine format strtotime() always accepts, such as '2025-01-31' or '2025-01-31 14:30:00'","Use supported relative expressions exactly: '-30 days', 'now', 'yesterday'","Quote the argument so the shell does not mangle it, and check the variable is non-empty and typo-free in your script"],"exampleFix":"# before\n$ bin/worker --since \"yesteday\"\n\n# after\n$ bin/worker --since \"2025-01-01\" \n# or\n$ bin/worker --since \"-30 days\"","handlingStrategy":"validation","validationCode":"// Mirror parseTimeArgument()'s rules before passing a CLI value.\nfunction parseTimeOrExit($time) {\n  if (!strlen($time)) { return null; }\n  $epoch = strtotime($time);\n  if ($epoch === false || $epoch <= 0) {\n    fwrite(STDERR, \"Unparseable time: {$time}\\n\");\n    exit(1);\n  }\n  return $epoch;\n}","typeGuard":"function isValidPhabricatorTime($time) {\n  if (!strlen($time)) { return true; } // empty is allowed -> null\n  $epoch = strtotime($time);\n  return $epoch !== false && $epoch > 0;\n}","tryCatchPattern":"try { $since = $workflow->parseTimeArgument($raw); } catch (PhutilArgumentUsageException $ex) { /* print message, show correct date examples, exit non-zero */ }","preventionTips":["Use unambiguous formats ('2025-01-31', '-30 days') in scripts instead of natural language","Shell-quote time arguments and check interpolated variables are non-empty"],"tags":["cli","date-parsing","strtotime","usage-error","phabricator"],"backgroundTag":"date-parse-failed","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}