Tommy has asked for the wisdom of the Perl Monks concerning the following question:
use Time::ParseDate; # ... # use some logic to find beginning of last week # note: (localtime)[6] = wday (0-6) where 0 = Sunday my($today) = (localtime)[6]; my($monday_lastw) = { # figure out days since monday of last week 0 => 6, 1 => 7, 2 => 8, 3 => 9, 4 => 10, 5 => 11, 6 => 12, }->{ $today }; my($saturday_lastw) = $monday_lastw - 6; # (days since sat. of last wk +) # get unix timestamp of the date on /monday/ of last week # (first second of last week) push(@parms, (parsedate(qq{$monday_lastw days ago 00:00:00}))[0]); # get unix timestamp of the date on /saturday/ of last week # (last second of last week) push(@parms, (parsedate(qq{$saturday_lastw days ago 23:59:59}))[0]);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A Better Way To Get Days Since Monday of Last Week
by Roy Johnson (Monsignor) on Jun 07, 2005 at 15:46 UTC | |
by Tommy (Chaplain) on Jun 07, 2005 at 15:54 UTC | |
|
Re: A Better Way To Get Days Since Monday of Last Week
by davidrw (Prior) on Jun 07, 2005 at 15:40 UTC | |
|
Re: A Better Way To Get Days Since Monday of Last Week
by dave0 (Friar) on Jun 07, 2005 at 15:42 UTC | |
|
Re: A Better Way To Get Days Since Monday of Last Week
by jbware (Chaplain) on Jun 07, 2005 at 15:37 UTC | |
|
Re: A Better Way To Get Days Since Monday of Last Week
by blazar (Canon) on Jun 07, 2005 at 15:46 UTC |