#!/usr/bin/perl use strict; use warnings; use Date::Manip; use feature 'say'; my $tz = new Date::Manip::TZ; my $dateLocal = ParseDate('now'); say $dateLocal; # From timeZone To timeZone my $dateTimeZone = Date_ConvTZ($dateLocal,"GMT","CST"); my $unixLocal = UnixDate($dateLocal,'%Y-%m-%d-%H-%M-%S'); say 'Local Timezone: ' . $unixLocal; my $unixTimeZone = UnixDate($dateTimeZone,'%Y-%m-%d-%H-%M-%S'); say 'Different Timezone: ' . $unixTimeZone; my $date1 = ParseDate($dateLocal); my $date2 = ParseDate($dateTimeZone); my $delta = DateCalc($date1, $date2, 1); say 'Difference between Timezones: ' . $delta; # Change Format my $str = UnixDate($dateLocal,"It is now %T on %b %e, %Y."); say $str; my $str_second = UnixDate($dateLocal,"It is now %T on %B %e, %Y."); say $str_second; my $str_decimal = UnixDate($dateLocal,"It is now decimal %T on %B %d, %Y."); say $str_decimal; # Add more time or subtract or do what ever you want with time my $deltastr = "12 hours ago"; my $date_past = DateCalc($dateLocal,$deltastr); # say $date; my $str_past = UnixDate($date_past,"It was 12 hours ago %T on %B %d, %Y."); say $str_past; __END__ $ perl test.pl 2017110109:11:31 Local Timezone: 2017-11-01-09-11-31 Different Timezone: 2017-11-01-17-11-31 Difference between Timezones: 0:0:0:0:8:0:0 It is now 09:11:31 on Nov 1, 2017. It is now 09:11:31 on November 1, 2017. It is now decimal 09:11:31 on November 01, 2017. It was 12 hours ago 21:11:31 on October 31, 2017.