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

Re: Detecting 1 day ago

by Random_Walk (Parson)
on Feb 25, 2006 at 15:03 UTC ( #532770=note: print w/ replies, xml ) Need Help??


in reply to Detecting 1 day ago

If you insist on a Perl way and as it looks, your date is in ISO 8601 format (YYYY-MM-DD HH:MM:SS) you can dervive the date stamp for 24 hours ago and do a string comparison

#!/usr/bin/perl use strict; use warnings; use POSIX; my $one_day = (24 * 60 * 60); while (<DATA>) { chomp; my $day_ago = strftime "%Y-%m-%d %H:%M:%S", localtime (time - $on +e_day); print "$_ is ", ( $_ gt $day_ago ? "recent" : "old" ) , $/; } __DATA__ 2005-23-02 02:02:02 2006-02-25 15:52:35
I love ISO 8601 dates for this feature.

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!


Comment on Re: Detecting 1 day ago
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2014-12-21 13:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (105 votes), past polls