Last active
December 20, 2015 02:09
-
-
Save kylejohnson/6054390 to your computer and use it in GitHub Desktop.
Show days and hour since now
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use strict; | |
| use warnings; | |
| use Time::Local; | |
| my $var = 'autosnap-hourly-2013-03-27_0900'; | |
| my @split = split('-', $var); | |
| my $year = $split[2]; | |
| my $month = $split[3]; | |
| my $day = substr($split[4], -7, 2); | |
| my $hour = substr($split[4], -4, 2); | |
| my $minute = substr($split[4], -2, 2); | |
| my $time = timelocal(0, $minute, $hour, $day, $month, $year); | |
| my $diff_days = int(($time - time()) / 86400); | |
| my $diff_hours = int((($time - time()) % 86400) / 3600); | |
| print "$diff_days days and $diff_hours hours\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment