Hi. I want to take a given date, supplied as a text string in YYY-MM-DD format, and determine if it's >= the current day. I'm having trouble with the timezone handling. The strptime seems to return the result in gmtime. I'm using Time::Piece::Plus to get the current day, but that's in localtime. What's the simplest way to get them both in gmtime, since I really don't care about the time or timezones. Adding a timezone to the strptime format string seems ugly.
#!/usr/bin/env perl use strict; use warnings; use Time::Piece::Plus; my $today = Time::Piece::Plus->today; my $date = Time::Piece::Plus->strptime("2015-04-20", '%Y-%m-%d'); print "Date: $date tzoffset=", $date->tzoffset, "\n"; print "Today: $today tzoffset=", $today->tzoffset, "\n"; print "Diff: ", ($date - $today), "\n";
Output:
Date: Mon Apr 20 00:00:00 2015 tzoffset=0 Today: Mon Apr 20 00:00:00 2015 tzoffset=-25200 Diff: -25200

In reply to Ignoring timezones when comparing dates with Time::Piece by Anonymous Monk

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.