Hello eniad,

It seems that fellow Monks have already addressed your problem, but I want to add something minor here also. Since there is a minor bug on the module would you consider also of using another module? For example I put together a very simple example on my favorite module Date::Manip regarding date manipulations.

The date formats that this modules can accept are many, just briefly see Date::Manip::Examples. The modules can convert in one step the human readable format date to epoch and vice versa.

I also included a minor comment in case you want to play with different time zone(s).

Sample of code bellow:

#!/usr/bin/perl use strict; use warnings; use Date::Manip; use feature 'say'; my @dates = ( "1899-06-24 09:44:00", "1900-12-31 23:59:59", "1901-01-01 00:00:00", "1960-12-31 23:59:59", "1966-06-24 09:44:00", "1968-12-31 23:59:59", "1969-01-01 00:00:00", "1969-12-31 23:59:59", "1970-01-01 00:00:01", "2000-01-01 00:00:00", "2017-06-24 23:59:59", "2018-06-24 09:44:00", "2238-06-24 09:44:00" ); foreach my $datestr (@dates) { my $epochSecs = UnixDate($datestr,'%s'); my $date = UnixDate( ParseDateString("epoch $epochSecs"), "%Y-%m-% +d %T"); say "Date value = ".$datestr.", epoch = ".$epochSecs.", date = " +.$date; } =timezone my $timezone = UnixDate( Date_ConvTZ( "today", 'CET', 'PST' ), "%Y-%m- +%d %T"); say $timezone; =cut __END__ $ perl test.pl Date value = 1899-06-24 09:44:00, epoch = -2225459760, date = 1899-06 +-24 09:44:00 Date value = 1900-12-31 23:59:59, epoch = -2177456401, date = 1900-12 +-31 23:59:59 Date value = 1901-01-01 00:00:00, epoch = -2177456400, date = 1901-01 +-01 00:00:00 Date value = 1960-12-31 23:59:59, epoch = -284000401, date = 1960-12- +31 23:59:59 Date value = 1966-06-24 09:44:00, epoch = -111165360, date = 1966-06- +24 09:44:00 Date value = 1968-12-31 23:59:59, epoch = -31539601, date = 1968-12-3 +1 23:59:59 Date value = 1969-01-01 00:00:00, epoch = -31539600, date = 1969-01-0 +1 00:00:00 Date value = 1969-12-31 23:59:59, epoch = -3601, date = 1969-12-31 23 +:59:59 Date value = 1970-01-01 00:00:01, epoch = -3599, date = 1970-01-01 00 +:00:01 Date value = 2000-01-01 00:00:00, epoch = 946681200, date = 2000-01-0 +1 00:00:00 Date value = 2017-06-24 23:59:59, epoch = 1498341599, date = 2017-06- +24 23:59:59 Date value = 2018-06-24 09:44:00, epoch = 1529826240, date = 2018-06- +24 09:44:00 Date value = 2238-06-24 09:44:00, epoch = 8472325440, date = 2238-06- +24 09:44:00

Hope this helps, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re: Date::Parse - how to correctly parse dates between 1901 and 1969 by thanos1983
in thread Date::Parse - how to correctly parse dates between 1901 and 1969 by eniad

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.