Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
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 surveying the Monastery: (6)
As of 2015-07-05 05:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls