The following code shows how to do the following in Perl:

  1. Get the epoch time
  2. Convert epoch seconds to readable format
  3. Convert readable format to epoch seconds

use Time::Local;
use strict;
#
# Get epoch seconds, convert to yyyy-mm-dd and then back to epoch seconds
#
# Epoch to dd/mm/yyy
###################################################
my $time1 = time;
my ($sec, $min, $hour, $day,$month,$year) = (localtime($time1))[0,1,2,3,4,5];
$month++ ; $year += 1900 ;
###################################################
#
# Display timestamp
################################################################
printf("\nTimestamp %04d-%02d-%02d %02d:%02d:%02d\n\n",
$year, $month, $day, $hour, $min, $sec);
###############################################################
#
# dd/mm/yyyy to Epoch
######################################################
my $time2 = timelocal($sec,$min,$hour,$day,$month-1,$year-1900);
######################################################

print "Epoch seconds original = $time1\n";
print "Epoch seconds calculated = $time2\n";