Re: time function

2004-09-20 Thread JupiterHost.Net

[EMAIL PROTECTED] wrote:
Greetings earthlings,
Hello,
I was wondering if I can get some help on this. I a function to which I pass the
current time. Let's call it func. I call it as follows:
$joe = func(time);
Now how do I use time but add one minute to it? For instance since time will
perl -e 'my $t = time();print $t\n;$t += 60;print $t\n;'
perldoc -f time
give me the current time, how do I tell it one minute from now?
Warmest regards
HTH :)
Lee.M - JupiterHost.Net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: time function

2004-09-20 Thread Gunnar Hjalmarsson
[EMAIL PROTECTED] wrote:
I was wondering if I can get some help on this. I a function to
which I pass the current time. Let's call it func. I call it as
follows: $joe = func(time);
Now how do I use time but add one minute to it? For instance
since time will give me the current time, how do I tell it one
minute from now?
$joe = func(time+60);
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: time function

2002-01-16 Thread Jeff 'japhy' Pinyan

On Jan 16, Roy Peters said:

I need someone to tell me the function that will convert time in this
format to epoch time: 1/17/2002 11:15 AM

If localtime() isn't good enough for you, then perhaps you'll want to use
the POSIX strftime() function, or you could hand-roll a solution.

  my ($min, $hr, $day, $mon, $year) = (localtime)[1..5];
  my $date = sprintf(
%d/%d/%d %d:%d %s,   # format string
$mon + 1, $day, $year + 1900,  # date
(($hr - 1) % 12 + 1), $min,# time
$hr  12 ? AM : PM # mode
  );

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for Regular Expressions in Perl published by Manning, in 2002 **
stu what does y/// stand for?  tenderpuss why, yansliterate of course.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: time function

2002-01-16 Thread Hanson, Robert

You could also use the Date::Parse module, part of the TimeDate package...

use Date::Parse;

my $epoch = str2time('1/17/2002 11:15 AM');


Rob

-Original Message-
From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 16, 2002 12:57 PM
To: Roy Peters
Cc: [EMAIL PROTECTED]
Subject: Re: time function


On Jan 16, Roy Peters said:

I need someone to tell me the function that will convert time in this
format to epoch time: 1/17/2002 11:15 AM

If localtime() isn't good enough for you, then perhaps you'll want to use
the POSIX strftime() function, or you could hand-roll a solution.

  my ($min, $hr, $day, $mon, $year) = (localtime)[1..5];
  my $date = sprintf(
%d/%d/%d %d:%d %s,   # format string
$mon + 1, $day, $year + 1900,  # date
(($hr - 1) % 12 + 1), $min,# time
$hr  12 ? AM : PM # mode
  );

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for Regular Expressions in Perl published by Manning, in 2002 **
stu what does y/// stand for?  tenderpuss why, yansliterate of course.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: time function

2002-01-16 Thread Peter Cornelius

To convert *to* seconds since the epoch you want the timelocal() function.
It's part of the Time::Local standard module and takes input in the form of
localtime's output.  From 'perldoc Time::Local'

use Time::Local;

$time = timelocal($sec,$min,$hours,$mday,$mon,$year);

so a completely worthless example would be

$epoch_time = timelocal(localtime());

In your case you just need to parse the string up to get a the individual
pieces.

Hope this helps,
Peter C.

-Original Message-
From: Roy Peters [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 16, 2002 9:45 AM
To: [EMAIL PROTECTED]
Subject: time function


I need someone to tell me the function that will convert time in this
format to epoch time: 1/17/2002 11:15 AM



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]