Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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

by mmartin (Monk)
on Sep 18, 2012 at 17:33 UTC ( #994318=note: print w/replies, xml ) Need Help??

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

Hey Anonymous Monk, thanks for the reply...

Sorry I forget exactly how the command looked I was asking about at that point... But I was able to get this working!!
And I was able to make it a little better then what I had posted at the end of this thread that I had my "resolution"
written in.

What I was doing was I had included an unneeded/unnecessary step. Here's what I did and what it is NOW...

FIRST, I had this one Perl command (below):
*This command would output the Seconds, Minutes, Hours, MDay, Month and Year.

perl -e 'use POSIX 'strftime'; $_n_days_ago = strftime("%S, %M, %k, %d, %m, %Y", localtime( time-$SECONDS )); print "$_n_days_ago\n"'

SECOND, I had this other Perl command (below):
*This command would take the output from the previous Perl command (i.e. $sec, $min, $hr, $mday, etc....) and would use
those values and feed them into this Perl Command to give me a UNIX Timestamp...

perl -e 'use Time::Local; print timelocal($sec,$min,$hour,$mday,$month,$year), "\n"'

Stupidly, not realizing that instead of those 2 commands, all's I needed to do was the 1st Perl Command and use the output
modifier --> "%s" to print a UNIX Timestamp.... Duhhh me!!

Here's the working Command:

PAST_TIMESTAMP=$(perl -e 'use POSIX 'strftime'; $_n_days_ago = strftime("%s", localtime(time-$ENV{TOTAL_SECONDS} )); print "$_n_days_ago"')

Anyway, thanks for all the help/suggestions, very much appreciated!!

Thanks Again,

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2018-05-25 20:49 GMT
Find Nodes?
    Voting Booth?