Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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 chanting in the Monastery: (3)
As of 2015-11-30 10:38 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (769 votes), past polls