TheAnswer1313:

OK ... the first lines of your code are choosing the first day to download, 3/31/08 in this case:

# get all important files from MLB.com, 3/31/08 through yesterday #$start = timelocal(0,0,0,31,2,108); $start = timelocal(0,0,0,31,2,108);

Read up on the timelocal function if you need more explanation of this part. In fact, read up on timelocal before continuing, or the next bit won't make sense.

You want to start downloading "yesterdays" file, instead of that hardcoded date. So you need to figure out how to get yesterday's date in the same format that timelocal is going to give it to you (so you don't need to change the code).

It turns out that timelocal returns the number of seconds since XXXXX. The time function returns the *current* date/time also in seconds since XXXXX. So time almost gives you what you want. Since there are 24 * 60 * 60 seconds in a day, if you subtract that from time, you'll get the same time yesterday. So you could change the lines above to:

# Start downloading from yesterday $start = time - 24*60*60;

The rest of the code (including $now) should be just fine. I hope this helps!

...roboticus

Note: The XXXXX is a specific date, but it's unimportant, so I didn't bother to specify.

Update: Added bit about $now.


In reply to Re^3: Help with Time by roboticus
in thread Help with Time by TheAnswer1313

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.