[Buffalo-pm] Getting Date/Time 1 Minute Ago...
Jim Brandt
cbrandt at buffalo.edu
Wed Sep 26 05:34:16 PDT 2007
One more example that should be platform independent:
use DateTime;
my $dt1 = DateTime->now();
print $dt1->hms() . "\n";
my $dt2 = $dt1->clone->subtract( minutes => 1 );
print $dt2->hms() . "\n";
Dan Magnuszewski wrote:
> Yeah, that's what I was looking for!
>
> Thanks.
>
> On 9/25/07, *Ben. B.* <bennymack at gmail.com <mailto:bennymack at gmail.com>>
> wrote:
>
> If you deal with a Unix time_t to start with, it really should be as
> simple as subtracting 60 seconds from it. Then use POSIX::strftime to
> format it however you like.
>
> perl -Mstrict -Mwarnings -MPOSIX -e 'my $time = time; printf( "NOW:
> %s, ONE MINUTE AGO: %s\n", scalar localtime $time, scalar localtime
> $time - 60 );'
>
> I can't think of any situations where that wouldn't work, but I'm
> often wrong...
>
> Ben
>
> On 9/25/07, Dan Magnuszewski <magnachef at gmail.com
> <mailto: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 <mailto:Buffalo-pm at pm.org>
> > http://mail.pm.org/mailman/listinfo/buffalo-pm
> >
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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
--
Jim Brandt
Administrative Computing Services
University at Buffalo
More information about the Buffalo-pm
mailing list