Epoch time is the number of seconds +or- from the epoch and is a signed integer value of some precision x. It is possible to do "time math" in seconds on epoch times. Use date/time string to create an epoch time and then add 24*60*60 seconds to it to get 24 hours from then if you want 23.5 hours then add(or subtract) 24*60*60-(30*60)..keep things in whole numbers (don't use .3 for a third of a day, use 8 hours *60 min*60 sec, etc...

So to see if your proposed date is in-between those times, convert it to epoch seconds also and do a numeric comparison.

You can use the stat func to figure out if that proposed date is Monday in your local time.

I would normally do everything in GMT or UTC as it is known today.

Of course I may have missed something here...

Update: oh, another point, when writing log files, etc. I use a format like this: 2007-10-06 1647. If leading zeroes are enforced for both date and time, then a simple alpha comparison or sort will get the right answer. To add 30 minutes to 2007-10-06 1647, I convert to epoch, add 30*60, then convert back to string (all this 24 hours, 60 minutes stuff is messy).


In reply to Re: Check current time between range of dates and times by Marshall
in thread Check current time between range of dates and times by AcidHawk

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.