Skip to content

Instantly share code, notes, and snippets.

@GuiltyDolphin
Last active January 15, 2016 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GuiltyDolphin/7071d533175f17aae032 to your computer and use it in GitHub Desktop.
Save GuiltyDolphin/7071d533175f17aae032 to your computer and use it in GitHub Desktop.
Quick script for parsing datestrings and returning the number of seconds since the Epoch they represent.
# Parse a date string (using DateTime::Format::HTTP) and return the number of seconds since epoch it represents.
date-to-epoch-perl () {
perl -MDateTime::Format::HTTP -E "say DateTime::Format::HTTP::parse_datetime('$1')->strftime('%s');";
}
# Better
date-to-epoch () {
date --date="$1" +%s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment