Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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, );

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://994117]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2018-06-19 09:30 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (111 votes). Check out past polls.