Skip to content

Instantly share code, notes, and snippets.

@puneetlakhina
Created November 7, 2011 22:32
Show Gist options
  • Save puneetlakhina/1346424 to your computer and use it in GitHub Desktop.
Save puneetlakhina/1346424 to your computer and use it in GitHub Desktop.
Convert localtime to unix timestamp
#!/usr/bin/perl
#Format of ip Month/Year/DateThour:minute:seconds
use Time::Local;
my ($date,$time) = split 'T' , $ARGV[$1];
#print $date."\n".$time."\n";
my ($month, $day, $year) = split '/', $date;
$month = $month - 1; #this is because timelocal wants the month to be zero indexed
#print $month."\n";
my ($hr, $min, $secs) = split ':', $time;
my $utctime = timelocal($secs,$min,$hr,$day,$month,$year);
print $utctime."\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment