You can get the current weekday from localtime(), and it isn't hard to go backwards and forwards from there to the start / end of the week.

Code to follow...

use strict; use warnings; my $t = time(); $t -= $t % 86400; my $wday = (localtime($t))[6]; my $s = $t - 86400 * $wday; my $e = $t + 86400 * (7 - $wday) - 1; @_ = localtime($s); $_[4]++; $_[5] += 1900; print "$_[4]-$_[3]-$_[5] to "; @_ = localtime($e); $_[4]++; $_[5] += 1900; print "$_[4]-$_[3]-$_[5]";
EDIT: Changed code slightly so $s and $e have the min timestamp on the first day and the max timestamp on the last day, respectively. You can now use them to check if a timestamp is inside the range.

In reply to Re: Findout the day range of the current week by TedPride
in thread Findout the day range of the current week 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.