Hello Cody Fendant,
Fellow Monks have provided you with the answer to your question. I would like to add another option here with one of my favorite modules regarding time manipulations Date::Manip.
Small sample of code with different timezone(s) and time subtraction. You can apply the time subtraction based on your time of receiving the email etc...
#!/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.
Hope this helps, BR.
Seeking for Perl wisdom...on the process of learning...not there...yet!
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.