Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Syntactic Confectionery Delight
 
PerlMonks  

Re: Timestamp of last monday

by Cristoforo (Chaplain)
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2014-04-19 05:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (478 votes), past polls