[rrd-users] Re: Using Time::localtime in Perl
Todd Caine
todd_caine at eli.net
Fri Jul 12 01:36:55 MEST 2002
Hi Max,
You don't *need* to use Time::localtime since it's just an object oriented
version of perl's built-in localtime() routine, but here's how you could do
it with Time::localtime anyways.
use Time::localtime;
my $t = localtime;
# you can just use printf() here if you don't want the string returned
my $time = sprintf(
"%02d:%02d:%02d %s",
($t->hour > 12) ? $t->hour - 12 : $t->hour,
$t->min,
$t->sec,
($t->hour < 12) ? 'AM' : 'PM'
);
print $time;
In the future it might be better to ask plain old Perl questions on
http://www.perlmonks.org/.
Regards,
Todd
TMTOWTDI
Max Kipness II wrote:
> I've just switched from using shell scripts to using perl with RRDs. I
> used to use the date function which was easy to format for 12hours
> using: /bin/date +%r. Now that I'm using Time::localtime I can't figure
> out how to do it.
>
> Does anyone know how to get this in a 12 hour format?
--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the rrd-users
mailing list