Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Use 'strftime' to calculate a date/time in the Past.

by Khen1950fx (Canon)
on Sep 17, 2012 at 21:35 UTC ( #994117=note: print w/ replies, xml ) Need Help??


in reply to Use 'strftime' to calculate a date/time in the Past.

FWIW, I used Time::Local for a one-liner:

perl -MTime::Local=timelocal -e 'print scalar localtime timelocal qw(3 +0 40 2 15 8 2012)';
Update: to get the day, date, and time 48 days ago:
#!/usr/bin/perl -l use strict; use autodie; use warnings; use POSIX 'strftime'; use Time::Local 'timelocal'; my $days_ago = '48'; ($days_ago) = strftime("%d", gmtime( time - $days_ago * 86400 )); print scalar localtime timelocal( 30, 40, 2, $days_ago, 7, 2012, );


Comment on Re: Use 'strftime' to calculate a date/time in the Past.
Select or Download Code
Re^2: Use 'strftime' to calculate a date/time in the Past.
by Anonymous Monk on Sep 17, 2012 at 21:42 UTC
    But you don't do date math, the thing the OP is trying to do

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2015-07-07 11:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls