© Moritz Lenz 2017

Moritz Lenz, Perl 6 Fundamentals , https://doi.org/10.1007/978-1-4842-2899-9_4

4. Datetime Conversion for the Command Line

Moritz Lenz

(1)Fürth, Bayern, Germany

Occasionally I work with a database that stores dates and datetimes as UNIX timestamps, a.k.a. the number of seconds since midnight 1970-01-01. Unlike the original author of the database and surrounding code, I cannot convert between UNIX timestamps and human-readable date formats in my head, so I write tools for that.

Our goal here is to write a small tool that converts back and forth between UNIX timestamps and dates/times:

$ autotime 2015-12-241450915200$ autotime 2015-12-24 11:23:001450956180$ autotime 14509152002015-12-24$ autotime 14509561802015-12-24 11:23:00

4.1 ...

Get Perl 6 Fundamentals : A Primer with Examples, Projects, and Case Studies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.