Skip to content

Instantly share code, notes, and snippets.

Created Jul 19, 2021
What would you like to do?
Command line app to convert to/from UNIX time.
#!/usr/bin/env php
if (count($argv) < 2) {
// Output current UNIX time if not argument specified
echo time()."\n";
if (strtolower($argv[1]) == "help") {
$currentScript = basename($argv[0]);
echo <<<EOL
{$currentScript} 1624032013
{$currentScript} "2000-12-25 23:59:59"
{$currentScript} yesterday
elseif (is_numeric($argv[1])) {
// Convert from UNIX timestamp
echo date(DATE_RSS, $argv[1])."\n";
else {
// Convert to UNIX timestamp
echo strtotime($argv[1])."\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment