Hello Monks,
I am trying to figure out a date/time in the past given I know it was 'a' days ago, 'b' hours ago, 'c' min ago and 'd' seconds ago.
I came across this perl command:
perl -e 'use POSIX 'strftime'; $_n_days_ago = strftime("%d", gmtime( t
+ime-$DAY_AGO*86400 )); print "$_n_days_ago\n"'
Which calculates the day "$DAYS_AGO" into the past. i.e. If "$DAYS_AGO = 2" then the resulting output would be "15" since today
is the 17th.
I've tried a couple different ways using a similar formatted command but it's not giving what I need.
I know the
"FORMAT" part of the strftime function would be -->
strftime( "%S, %M, %k, %d, %m, %Y",...
Which the resulting Output I want would be in the format:
"Seconds, Minutes, Hours, Day-of-Month, Month, Year"
For Example:
If I want the date and time from, 2 days, 10 hours, 20 minutes, and 30 seconds Ago the output would be:
# If the current date/time was "9/17/2012 12:00:00"....
# (i.e. time is in 24-Hour format)
The Output would be:
"30, 40, 02, 15, 09, 2012"
Which in date format is = "9/15/2012 02:40:30"
Could anyone tell me if this is possible using the functions above?
Any suggestions would be very much appreciated..!
Thanks in Advance,
Matt