Does the system you work on have its epoch set to zero for 01 January 2000, or does it use the standard Linux epoch of 01 January 1970?

(I am ignoring the issue of whether your year 2000 epoch starts at midnight or at noon!)

Try this to see what it's set at:

#!/usr/bin/perl # use Time::Local; # use strict; use warnings; # note months are 0 to 11 - hence the '-1' # timegm is seconds, minutes, hours, day, month -1, year my $two_k_epoch = timegm( 0, 0, 0, 1, 0, 2000 ); # midnight 01 January + 2000 - change to noon if required my $linux_epoch = timegm( 0, 0, 0, 1, 0, 1970 ); # midnight 01 January + 1970 print "2K epoch: $two_k_epoch\tLinux epoch: $linux_epoch\n";

If the 2K epoch is zero, then you shouldn't have to do anything, as all calculations will be using that epoch. As long as the calculated seconds are not transferred to another system that is using the Linux epoch there shouldn't be any problems, but it's not something I can test.

If however your system is using standard Linux epoch ($linux_epoch is zero) the you will have to subtract the year 2000 value from all calculated seconds and add it back again before converting seconds back to eye-readable values.

You will still need to know whether you are working in UTC or local time.

When you used 'DateTime' in your question title, did you specifically mean the perl DateTime module, or just any date and time module. From what I have just read, DateTime uses an epoch based on year 1 (long before the Gregorian calendar was invented),

 In this calendar, the first day of the calendar (the epoch), is the first day of year 1

As an aside, I like Date::Calc as I do a fair bit of adding/subtracting days or hours from start dates/times


In reply to Re: How to use a different epoch with DateTime by anita2R
in thread How to use a different epoch with DateTime by thimes

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.