Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

RE: Get the date (MySQL style) for X days ago

by Anonymous Monk
on Feb 17, 2000 at 10:25 UTC ( [id://3606]=note: print w/replies, xml ) Need Help??


in reply to Get the date (MySQL style) for X days ago

Perhaps I'm missing something, but you're doing way too many calculations in there. You're taking epoch seconds, computing the date in month, day, and year, then converting back to epoch seconds? In addition, you get a warning:
# "my" variable $date masks earlier declaration in same scope.
You declared $date twice as a my variable. Try this:
sub calcDate { my $offset = shift; my($mday, $mon, $year) = (localtime(time - $offset * 86400))[3..5]; return sprintf "%04s-%02s-%02s", $year + 1900, $mon + 1, $mday; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-19 23:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found