[Buffalo-pm] Getting Date/Time 1 Minute Ago...

Kevin Eye eye at buffalo.edu
Tue Sep 25 13:40:53 PDT 2007


I agree with Josh -- time()-60, time()-86400 for yesterday, etc. That's what
I always do.

If you're looking to take "10/1/07 00:00" - 1 minute and get "9/30/07 23:59"
you could parse it yourself, use localtime, then subtract from the minute
(or whatever) value and then run it back through the built-in
Time::Local::timelocal_nocheck() function. timelocal_nocheck does the
inverse of localtime and accepts out-of-bounds values like -1 or 61 minutes,
etc. 

Also, you could use my personal favorite date/time modules: Time::ParseDate
and Time::CTime. You'd say something like:

strftime('%D %H:%M', localtime(parsedate("10/1/07 00:00")-60))

Also, I believe the DateTime CPAN module is regarded to be extremely
comprehensive and object-oriented, but it's slow and gigantic.

 - Kevin



On 9/25/07 3:49 PM, "Dan Magnuszewski" <magnachef at gmail.com> wrote:

> All,
> 
> I'm looking for a module or Linux command that will allow me to get the
> date/time one minute ago. I know this sounds trivial (just subtract 1 from
> minute) but it can get messy  at midnight on the first of the month, or the
> first day of the year, etc. It's not hard, just a pain to code that up, and
> it'd be nice if there was already something that could do the work for me
> :-)
> 
> Does anyone know of anything that will do this?
> 
> -Dan
> _______________________________________________
> Buffalo Perl Mongers Homepage
> http://buffalo.pm.org
> 
> Buffalo-pm mailing list
> Buffalo-pm at pm.org
> http://mail.pm.org/mailman/listinfo/buffalo-pm

-- 
Kevin Eye
Web Applications Developer
Marketing and Creative Services
University at Buffalo
330 Crofts Hall
Buffalo, NY 14260
eye at buffalo.edu
phone (716) 645-5000 x1435
fax (716) 645-3765




More information about the Buffalo-pm mailing list