Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Timestamp of last monday

by Cristoforo (Deacon)
on Nov 19, 2011 at 19:01 UTC ( #938995=note: print w/ replies, xml ) Need Help??

in reply to Timestamp of last monday

#!/usr/bin/perl use strict; use warnings; use POSIX qw/ strftime /; # Script to get prior Monday (if today is Mon, then Mon a week ago). print scalar localtime, "\n", last_monday(localtime); sub last_monday { my ($wday, @dmy) = @_[6, 3..5]; # (will work across month, year boundries) $dmy[0] -= ($wday+6) % 7 || 7; # $dmy[0] == mday return strftime "%Y%m%d000000", 0,0,0,@dmy; }

Comment on Re: Timestamp of last monday
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://938995]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2015-06-30 09:16 GMT
Find Nodes?
    Voting Booth?

    What kind of chocolate gives you the most pleasure?

    Results (779 votes), past polls