Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by Anonymous Monk
on Sep 17, 2012 at 19:28 UTC ( #994082=note: print w/ replies, xml ) Need Help??


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

I've tried a couple different ways using a similar formatted command but it's not giving what I need. Could anyone tell me if this is possible using the functions above?

Its possible, show what you tried


Comment on Re: Use 'strftime' to calculate a date/time in the Past.
Re^2: Use 'strftime' to calculate a date/time in the Past.
by mmartin (Monk) on Sep 18, 2012 at 17:33 UTC
    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,
    Matt

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2014-07-25 03:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (167 votes), past polls