Skip to content

Instantly share code, notes, and snippets.

@adkinss
Created August 12, 2016 15:55
Show Gist options
  • Save adkinss/dbf992591d80e1737dbd14269635fca8 to your computer and use it in GitHub Desktop.
Save adkinss/dbf992591d80e1737dbd14269635fca8 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
use strict;
# Without parameters, this script display the current time in epoch and date
# format. Supplied parameters need to be epoch times, which is each displayed
# in epoch and date format. The following are example outputs of the script:
#
# $ ./ctime.pl
# 1471016994 = Fri Aug 12 11:49:54 2016
#
# $ ./ctime.pl $(date +%s) $(date --date=yesterday +%s)
# 1471016995 = Fri Aug 12 11:49:55 2016
# 1470930595 = Thu Aug 11 11:49:55 2016
push @ARGV, time() unless (@ARGV);
foreach my $arg (@ARGV) {
my $time = localtime($arg);
print "$arg = $time\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment