[18849] in Perl-Users-Digest
Perl-Users Digest, Issue: 1017 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 30 03:10:38 2001
Date: Wed, 30 May 2001 00:10:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <991206617-v10-i1017@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 30 May 2001 Volume: 10 Number: 1017
Today's topics:
Re: The FlakeyMind/Bryce Jacobs FAQ (v0.1) (Martien Verbruggen)
time <"relaxedrob@optushome.com.au">
Re: time <godzilla@stomp.stomp.tokyo>
Re: time <wyzelli@yahoo.com>
Re: time <"relaxedrob@optushome.com.au">
Re: time <"relaxedrob@optushome.com.au">
Re: time <krahnj@acm.org>
Re: time <godzilla@stomp.stomp.tokyo>
Re: time <godzilla@stomp.stomp.tokyo>
Re: time <"relaxedrob@optushome.com.au">
use Module (if it exists) <todd@designsouth.net>
Web Based Email Messenger 4 is Out!!! <necrorising@hotmail.com>
Re: what does this mean? (Bernard El-Hagin)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 30 May 2001 06:46:25 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: The FlakeyMind/Bryce Jacobs FAQ (v0.1)
Message-Id: <slrn9h95q2.epd.mgjv@verbruggen.comdyn.com.au>
On Wed, 30 May 2001 00:03:24 GMT,
Thaddeus L Olczyk <olczyk@interaccess.com> wrote:
>
> More to come later.
If so, please don't crosspost to clp.misc anymore. The fact that
topmind used to post here in the past doesn't make any of the post
very topical, and to be frank, we've got our own trolls to deal with
here.
Thank you,
Martien
--
Martien Verbruggen |
Interactive Media Division | I used to have a Heisenbergmobile.
Commercial Dynamics Pty. Ltd. | Every time I looked at the
NSW, Australia | speedometer, I got lost.
------------------------------
Date: Wed, 30 May 2001 03:56:05 GMT
From: "Rob" <"relaxedrob@optushome.com.au">
Subject: time
Message-Id: <pb_Q6.5015$25.18192@news1.eburwd1.vic.optushome.com.au>
Howdy all!
Could anyone help me out with my time problem please?
I want to get the current time in this format:
DD-MM-YYYY HH:MI AM
These are the three methods I have been testing.
Method One
my $perltime = time();
my $time = time2str($perltime);
printf "<p>Time is $time</p>";
OUTPUT
Time is Wed, 30 May 2001 03:31:56 GMT
Method Two
my $sec, my $min, my $hour, my $mday, my $mon, my $year, my $wday, my $yday;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime($perltime);
$year += 1900;
$mon ++;
my $now_string = $mday."-".$mon."-".$year." ".$hour.":".$min." ";
print "<p>Or time is $now_string</p>";
OUTPUT
Or time is 30-5-2001 3:31
Method Three
print sprintf ("<p>OR time is %02d-%02d-%04d %02d:%02d ", $mday, $mon, $year,
$hour, $min);
OUTPUT
OR time is 30-05-2001 03:31
I have two problems with these three outputs:
1.
They are all two hours too fast! System time when these were executed was 1:31
pm..
2.
How do I get hold of AM/PM information. I notice that all three of these were in
12 hour format with no indication of AM or PM..
Thanks for any advice!
Rob
------------------------------
Date: Tue, 29 May 2001 21:22:11 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: time
Message-Id: <3B147573.911CBB5C@stomp.stomp.tokyo>
Rob wrote:
> Could anyone help me out with my time problem please?
> I want to get the current time in this format:
> DD-MM-YYYY HH:MI AM
(snipped code examples)
> How do I get hold of AM/PM information. I notice that all three of these were in
> 12 hour format with no indication of AM or PM..
Godzilla!
--
#!perl
print "Content-Type: text/plain\n\n";
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
my ($choctaw_hour) = $hour;
my ($choctaw_hour2) = $hour;
if ($sec < 10)
{ $sec = "0$sec"; }
if ($min < 10)
{ $min = "0$min";}
if ($hour < 10)
{ $hour = "0$hour"; }
if ($mon < 10)
{ $mon = "0$mon"; }
if ($mday < 10)
{ $mday = "0$mday"; }
my ($month) = ($mon + 1);
my ($year) = ($year + 1900);
my ($am_pm) = "AM";
if ($hour > 12)
{ $hour = $hour -12; $am_pm= "PM"; }
my ($local_timezone) = "PST (-0800 GMT)";
my (@day_of_week) = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
my (@month) = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec");
# format one:
$date = "$day_of_week[$wday], $month[$mon] $mday, $hour:$min $am_pm $local_timezone";
print "Format One:\n $date\n\n";
# format two:
$date = "$hour\:$min\:$sec $month/$mday/$year";
print "Format Two:\n $date\n\n";
# format three:
$date = "$month/$mday/$year $hour\:$min\:$sec";
print "Format Three:\n $date\n\n";
# format four:
print "Format Four:\n ", $month, "_", $mday, "_", $year, "\n\n";
# format five:
if ($month < 10)
{ $month ="0$month"; }
print "Format Five:\n ", $month, "_", $mday, "_", $year, "\n\n";
# in my native tongue, English Variant Choctaw:
@day_of_week = ("Nitak Hollo", "Monti", "Tusti", "Winsti",
"Hlusti", "Flaiti", "Satate");
@month = ("Chanueli", "Febueli", "Macha", "Eplil", "Me", "Chuni",
"Chuli", "Akas", "Siptimba", "Aktoba", "Nofimba", "Tisimba");
$date = "$day_of_week[$wday] - $month[$mon] $mday - $hour:$min $am_pm";
print "English Variant Choctaw:\n $date\n\n";
# in my native tongue, True Choctaw:
$am_pm = "Nitak";
if ($choctaw_hour == 12)
{ $am_pm = "Tabokoli"; }
if ($choctaw_hour > 12)
{ $choctaw_hour = $choctaw_hour - 12; $am_pm = "Ninak"; }
@day_of_week = ("Nitak Hollo", "Nitak Hollotuk Onna",
"Nitak Hollotuk Imisha", "Nitak Hollotuk Imisha Nitak Tuchina",
"Nitak Hollotuk Imisha Nitak Usta", "Nitak Hollotuk Imisha Tahlapi",
"Nitak Hollo Nakfish");
@month = ("Hashi Koi Nakfi Ushi", "Hashi Watonlak", "Hashi Mahli", "Tik I Hashi",
"Hashi Bihi", "Hashi Bissa", "Hashi Kafi", "Hashi Takkon", "Hashi Hoponi",
"Hochafo Iskitini", "Hochafo Chito", "Hashi Koi Chito");
$date = "$day_of_week[$wday] - $month[$mon] $mday - $choctaw_hour:$min $am_pm";
print "True Choctaw Native Tongue:\n $date\n\n";
# English literal translation:
$am_pm = "Morning";
if ($choctaw_hour2 == 12)
{ $am_pm = "Noon"; }
if ($choctaw_hour2 > 12)
{ $choctaw_hour = $choctaw_hour2 - 12; $am_pm = "Night"; }
@day_of_week = ("Holy Day", "Day After Holy Day", "Second Day After Holy Day",
"Three Days After Holy Day", "Fourth Day After Holy Day",
"Fifth Day After Holy Day", "Holy Day's Brother");
@month = ("Lion's Little Brother Month", "Crane Month", "Wind Month",
"Woman's Month", "Mulberry Month", "Blackberry Month",
"Sassafras Month", "Peach Month", "Cooking Month",
"Little Hunger Month", "Big Hunger Month", "Big Lion Month");
$date = "$day_of_week[$wday] - $month[$mon] $mday - $choctaw_hour2:$min $am_pm";
print "English Literal Translation:\n $date";
exit;
PRINTED RESULTS:
________________
Format One:
Tue, May 29, 9:15 PM PST (-0800 GMT)
Format Two:
9:15:17 5/29/2001
Format Three:
5/29/2001 9:15:17
Format Four:
5_29_2001
Format Five:
05_29_2001
English Variant Choctaw:
Tusti - Me 29 - 9:15 PM
True Choctaw Native Tongue:
Nitak Hollotuk Imisha - Hashi Bihi 29 - 9:15 Ninak
English Literal Translation:
Second Day After Holy Day - Mulberry Month 29 - 21:15 Night
------------------------------
Date: Wed, 30 May 2001 14:12:20 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: time
Message-Id: <iQ_Q6.2$PZ3.570@vic.nntp.telstra.net>
"Rob" <"relaxedrob@optushome.com.au"> wrote in message
news:pb_Q6.5015$25.18192@news1.eburwd1.vic.optushome.com.au...
> Howdy all!
>
> Could anyone help me out with my time problem please?
>
> I want to get the current time in this format:
> DD-MM-YYYY HH:MI AM
>
> These are the three methods I have been testing.
>
> Method One
> my $perltime = time();
> my $time = time2str($perltime);
time2str is not a Perl function. Calling locatime or gmtime in a scalar
context provides that output directly anyway.
> printf "<p>Time is $time</p>";
>
> OUTPUT
> Time is Wed, 30 May 2001 03:31:56 GMT
>
> Method Two
> my $sec, my $min, my $hour, my $mday, my $mon, my $year, my $wday, my
$yday;
>
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime($perltime);
Save a line and some typing by :
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime($perltime);
The default argument to gmtime() and localtime() is time() anyway so you
could just write:
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime;
Though I think you want:
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = localtime()
> $year += 1900;
> $mon ++;
Good
> my $now_string = $mday."-".$mon."-".$year." ".$hour.":".$min." ";
>
> print "<p>Or time is $now_string</p>";
>
> OUTPUT
> Or time is 30-5-2001 3:31
>
> Method Three
> print sprintf ("<p>OR time is %02d-%02d-%04d %02d:%02d ", $mday, $mon,
$year,
> $hour, $min);
>
> OUTPUT
> OR time is 30-05-2001 03:31
>
>
> I have two problems with these three outputs:
> 1.
> They are all two hours too fast! System time when these were executed was
1:31
> pm..
The documentation does not speak of AM or PM, since the time is given as
seconds since the epoch, and the default is 24 hour time. You would need to
convert to AM or PM yourself. I am guessing you are located two hours west
of Greenwich (time zone anyway) since the gmtime and localtime functions
give different times.
>
> 2.
> How do I get hold of AM/PM information. I notice that all three of these
were in
> 12 hour format with no indication of AM or PM..
As mentioned above, convert to 12 hour yourself if needed.
Wyzelli
--
@x='074117115116032097110111116104101114032080101114108032104097099107101114
'=~/(...)/g;
print chr for @x;
------------------------------
Date: Wed, 30 May 2001 05:16:59 GMT
From: "Rob" <"relaxedrob@optushome.com.au">
Subject: Re: time
Message-Id: <fn%Q6.5029$25.18280@news1.eburwd1.vic.optushome.com.au>
*down on my knees*
I'm not worthy!
I'm not worthy!
I'm not worthy!
:)
Thank you very much!
Rob
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3B147573.911CBB5C@stomp.stomp.tokyo...
> Rob wrote:
>
> > Could anyone help me out with my time problem please?
>
> > I want to get the current time in this format:
> > DD-MM-YYYY HH:MI AM
>
> (snipped code examples)
>
> > How do I get hold of AM/PM information. I notice that all three of these
were in
> > 12 hour format with no indication of AM or PM..
>
>
> Godzilla!
> --
>
> #!perl
>
> print "Content-Type: text/plain\n\n";
>
> my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
> my ($choctaw_hour) = $hour;
> my ($choctaw_hour2) = $hour;
>
> if ($sec < 10)
> { $sec = "0$sec"; }
> if ($min < 10)
> { $min = "0$min";}
> if ($hour < 10)
> { $hour = "0$hour"; }
> if ($mon < 10)
> { $mon = "0$mon"; }
> if ($mday < 10)
> { $mday = "0$mday"; }
>
> my ($month) = ($mon + 1);
> my ($year) = ($year + 1900);
> my ($am_pm) = "AM";
> if ($hour > 12)
> { $hour = $hour -12; $am_pm= "PM"; }
>
> my ($local_timezone) = "PST (-0800 GMT)";
> my (@day_of_week) = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
> my (@month) = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
> "Sep", "Oct", "Nov", "Dec");
>
>
> # format one:
>
> $date = "$day_of_week[$wday], $month[$mon] $mday, $hour:$min $am_pm
$local_timezone";
>
> print "Format One:\n $date\n\n";
>
>
> # format two:
>
> $date = "$hour\:$min\:$sec $month/$mday/$year";
>
> print "Format Two:\n $date\n\n";
>
>
> # format three:
>
> $date = "$month/$mday/$year $hour\:$min\:$sec";
>
> print "Format Three:\n $date\n\n";
>
>
> # format four:
>
> print "Format Four:\n ", $month, "_", $mday, "_", $year, "\n\n";
>
>
> # format five:
>
> if ($month < 10)
> { $month ="0$month"; }
>
> print "Format Five:\n ", $month, "_", $mday, "_", $year, "\n\n";
>
>
> # in my native tongue, English Variant Choctaw:
>
> @day_of_week = ("Nitak Hollo", "Monti", "Tusti", "Winsti",
> "Hlusti", "Flaiti", "Satate");
> @month = ("Chanueli", "Febueli", "Macha", "Eplil", "Me", "Chuni",
> "Chuli", "Akas", "Siptimba", "Aktoba", "Nofimba", "Tisimba");
>
> $date = "$day_of_week[$wday] - $month[$mon] $mday - $hour:$min $am_pm";
> print "English Variant Choctaw:\n $date\n\n";
>
>
> # in my native tongue, True Choctaw:
>
> $am_pm = "Nitak";
>
> if ($choctaw_hour == 12)
> { $am_pm = "Tabokoli"; }
> if ($choctaw_hour > 12)
> { $choctaw_hour = $choctaw_hour - 12; $am_pm = "Ninak"; }
>
> @day_of_week = ("Nitak Hollo", "Nitak Hollotuk Onna",
> "Nitak Hollotuk Imisha", "Nitak Hollotuk Imisha Nitak
Tuchina",
> "Nitak Hollotuk Imisha Nitak Usta", "Nitak Hollotuk Imisha
Tahlapi",
> "Nitak Hollo Nakfish");
>
> @month = ("Hashi Koi Nakfi Ushi", "Hashi Watonlak", "Hashi Mahli", "Tik I
Hashi",
> "Hashi Bihi", "Hashi Bissa", "Hashi Kafi", "Hashi Takkon", "Hashi
Hoponi",
> "Hochafo Iskitini", "Hochafo Chito", "Hashi Koi Chito");
>
> $date = "$day_of_week[$wday] - $month[$mon] $mday - $choctaw_hour:$min
$am_pm";
>
> print "True Choctaw Native Tongue:\n $date\n\n";
>
>
> # English literal translation:
>
> $am_pm = "Morning";
>
> if ($choctaw_hour2 == 12)
> { $am_pm = "Noon"; }
>
> if ($choctaw_hour2 > 12)
> { $choctaw_hour = $choctaw_hour2 - 12; $am_pm = "Night"; }
>
> @day_of_week = ("Holy Day", "Day After Holy Day", "Second Day After Holy Day",
> "Three Days After Holy Day", "Fourth Day After Holy Day",
> "Fifth Day After Holy Day", "Holy Day's Brother");
>
> @month = ("Lion's Little Brother Month", "Crane Month", "Wind Month",
> "Woman's Month", "Mulberry Month", "Blackberry Month",
> "Sassafras Month", "Peach Month", "Cooking Month",
> "Little Hunger Month", "Big Hunger Month", "Big Lion Month");
>
> $date = "$day_of_week[$wday] - $month[$mon] $mday - $choctaw_hour2:$min
$am_pm";
>
> print "English Literal Translation:\n $date";
>
>
> exit;
>
>
> PRINTED RESULTS:
> ________________
>
> Format One:
> Tue, May 29, 9:15 PM PST (-0800 GMT)
>
> Format Two:
> 9:15:17 5/29/2001
>
> Format Three:
> 5/29/2001 9:15:17
>
> Format Four:
> 5_29_2001
>
> Format Five:
> 05_29_2001
>
> English Variant Choctaw:
> Tusti - Me 29 - 9:15 PM
>
> True Choctaw Native Tongue:
> Nitak Hollotuk Imisha - Hashi Bihi 29 - 9:15 Ninak
>
> English Literal Translation:
> Second Day After Holy Day - Mulberry Month 29 - 21:15 Night
------------------------------
Date: Wed, 30 May 2001 05:27:44 GMT
From: "Rob" <"relaxedrob@optushome.com.au">
Subject: Re: time
Message-Id: <kx%Q6.5035$25.18262@news1.eburwd1.vic.optushome.com.au>
I am still stuck though my friend.. :)
This works perfectly as a script through perl, but when I put it into a html
page, I get, for example:
Format One: Sun, Jan 0, 0:0 AM PST (-0800 GMT)
Rob
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3B147573.911CBB5C@stomp.stomp.tokyo...
> Rob wrote:
>
> > Could anyone help me out with my time problem please?
>
> > I want to get the current time in this format:
> > DD-MM-YYYY HH:MI AM
>
> (snipped code examples)
>
> > How do I get hold of AM/PM information. I notice that all three of these
were in
> > 12 hour format with no indication of AM or PM..
>
>
> Godzilla!
> --
>
> #!perl
>
> print "Content-Type: text/plain\n\n";
>
> my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
> my ($choctaw_hour) = $hour;
> my ($choctaw_hour2) = $hour;
>
> if ($sec < 10)
> { $sec = "0$sec"; }
> if ($min < 10)
> { $min = "0$min";}
> if ($hour < 10)
> { $hour = "0$hour"; }
> if ($mon < 10)
> { $mon = "0$mon"; }
> if ($mday < 10)
> { $mday = "0$mday"; }
>
> my ($month) = ($mon + 1);
> my ($year) = ($year + 1900);
> my ($am_pm) = "AM";
> if ($hour > 12)
> { $hour = $hour -12; $am_pm= "PM"; }
>
> my ($local_timezone) = "PST (-0800 GMT)";
> my (@day_of_week) = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
> my (@month) = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
> "Sep", "Oct", "Nov", "Dec");
>
>
> # format one:
>
> $date = "$day_of_week[$wday], $month[$mon] $mday, $hour:$min $am_pm
$local_timezone";
>
> print "Format One:\n $date\n\n";
>
>
> # format two:
>
> $date = "$hour\:$min\:$sec $month/$mday/$year";
>
> print "Format Two:\n $date\n\n";
>
>
> # format three:
>
> $date = "$month/$mday/$year $hour\:$min\:$sec";
>
> print "Format Three:\n $date\n\n";
>
>
> # format four:
>
> print "Format Four:\n ", $month, "_", $mday, "_", $year, "\n\n";
>
>
> # format five:
>
> if ($month < 10)
> { $month ="0$month"; }
>
> print "Format Five:\n ", $month, "_", $mday, "_", $year, "\n\n";
>
>
> # in my native tongue, English Variant Choctaw:
>
> @day_of_week = ("Nitak Hollo", "Monti", "Tusti", "Winsti",
> "Hlusti", "Flaiti", "Satate");
> @month = ("Chanueli", "Febueli", "Macha", "Eplil", "Me", "Chuni",
> "Chuli", "Akas", "Siptimba", "Aktoba", "Nofimba", "Tisimba");
>
> $date = "$day_of_week[$wday] - $month[$mon] $mday - $hour:$min $am_pm";
> print "English Variant Choctaw:\n $date\n\n";
>
>
> # in my native tongue, True Choctaw:
>
> $am_pm = "Nitak";
>
> if ($choctaw_hour == 12)
> { $am_pm = "Tabokoli"; }
> if ($choctaw_hour > 12)
> { $choctaw_hour = $choctaw_hour - 12; $am_pm = "Ninak"; }
>
> @day_of_week = ("Nitak Hollo", "Nitak Hollotuk Onna",
> "Nitak Hollotuk Imisha", "Nitak Hollotuk Imisha Nitak
Tuchina",
> "Nitak Hollotuk Imisha Nitak Usta", "Nitak Hollotuk Imisha
Tahlapi",
> "Nitak Hollo Nakfish");
>
> @month = ("Hashi Koi Nakfi Ushi", "Hashi Watonlak", "Hashi Mahli", "Tik I
Hashi",
> "Hashi Bihi", "Hashi Bissa", "Hashi Kafi", "Hashi Takkon", "Hashi
Hoponi",
> "Hochafo Iskitini", "Hochafo Chito", "Hashi Koi Chito");
>
> $date = "$day_of_week[$wday] - $month[$mon] $mday - $choctaw_hour:$min
$am_pm";
>
> print "True Choctaw Native Tongue:\n $date\n\n";
>
>
> # English literal translation:
>
> $am_pm = "Morning";
>
> if ($choctaw_hour2 == 12)
> { $am_pm = "Noon"; }
>
> if ($choctaw_hour2 > 12)
> { $choctaw_hour = $choctaw_hour2 - 12; $am_pm = "Night"; }
>
> @day_of_week = ("Holy Day", "Day After Holy Day", "Second Day After Holy Day",
> "Three Days After Holy Day", "Fourth Day After Holy Day",
> "Fifth Day After Holy Day", "Holy Day's Brother");
>
> @month = ("Lion's Little Brother Month", "Crane Month", "Wind Month",
> "Woman's Month", "Mulberry Month", "Blackberry Month",
> "Sassafras Month", "Peach Month", "Cooking Month",
> "Little Hunger Month", "Big Hunger Month", "Big Lion Month");
>
> $date = "$day_of_week[$wday] - $month[$mon] $mday - $choctaw_hour2:$min
$am_pm";
>
> print "English Literal Translation:\n $date";
>
>
> exit;
>
>
> PRINTED RESULTS:
> ________________
>
> Format One:
> Tue, May 29, 9:15 PM PST (-0800 GMT)
>
> Format Two:
> 9:15:17 5/29/2001
>
> Format Three:
> 5/29/2001 9:15:17
>
> Format Four:
> 5_29_2001
>
> Format Five:
> 05_29_2001
>
> English Variant Choctaw:
> Tusti - Me 29 - 9:15 PM
>
> True Choctaw Native Tongue:
> Nitak Hollotuk Imisha - Hashi Bihi 29 - 9:15 Ninak
>
> English Literal Translation:
> Second Day After Holy Day - Mulberry Month 29 - 21:15 Night
------------------------------
Date: Wed, 30 May 2001 05:31:32 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: time
Message-Id: <3B1485C7.4210D1FB@acm.org>
Rob wrote:
>
> Howdy all!
>
> Could anyone help me out with my time problem please?
>
> I want to get the current time in this format:
> DD-MM-YYYY HH:MI AM
use POSIX qw(strftime);
print strftime( "%d-%m-%Y %I:%M %p", localtime );
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 29 May 2001 22:39:47 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: time
Message-Id: <3B1487A3.58DA5A86@stomp.stomp.tokyo>
Rob wrote:
> Thank you very much!
De nada.
You have many options now. Should you still have
problems with your time being off by two hours,
simply substract two hours from your $hour or equal
variable before you do any formatting. It is not
uncommon for a server to be located in a time zone
different than a user.
I understand your clocks run backwards just
as your water drains backwards.
Incidently, my code is almost all old fashion
Perl 4 coding which all here claim is typical
Cargo Cult and unworthy of use. My very first
posting to this group so very long ago, was
code almost identical to what I posted in this
article. Boy, did people here toss temper tantrums,
scream, cuss and rag on me for weeks. Most claimed
my code wouldn't run. * laughs *
They are still angry even today.
Godzilla!
------------------------------
Date: Tue, 29 May 2001 22:48:10 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: time
Message-Id: <3B14899A.127F301B@stomp.stomp.tokyo>
Rob wrote:
> I am still stuck though my friend.. :)
> This works perfectly as a script through perl, but when I put it into a html
> page, I get, for example:
> Format One: Sun, Jan 0, 0:0 AM PST (-0800 GMT)
Boys....
Pick a format. Experiment with it. Learn, darn it.
Godzilla!
--
#!perl
print "Content-Type: text/plain\n\n";
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
if ($sec < 10)
{ $sec = "0$sec"; }
if ($min < 10)
{ $min = "0$min";}
if ($hour < 10)
{ $hour = "0$hour"; }
if ($mon < 10)
{ $mon = "0$mon"; }
if ($mday < 10)
{ $mday = "0$mday"; }
my ($month) = ($mon + 1);
my ($year) = ($year + 1900);
my ($am_pm) = "AM";
if ($hour > 12)
{ $hour = $hour -12; $am_pm= "PM"; }
my $local_timezone = "PST (-0800 GMT)";
my (@day_of_week) = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
my (@month) = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec");
$date = "$day_of_week[$wday], $month[$mon] $mday, $hour:$min $am_pm $local_timezone";
print $date;
print "\n\n";
$date = "$day_of_week[$wday], $month[$mon] $mday, $hour:$min $am_pm";
print $date;
PRINTED RESULTS:
________________
Tue, May 29, 10:44 PM PST (-0800 GMT)
Tue, May 29, 10:44 PM
------------------------------
Date: Wed, 30 May 2001 06:10:13 GMT
From: "Rob" <"relaxedrob@optushome.com.au">
Subject: Re: time
Message-Id: <990R6.5056$25.18324@news1.eburwd1.vic.optushome.com.au>
Experimented.. Learnt.. Found the problem.. Fixed the problem.
GMT + 10 *and* water runs down the plug hole backwards..
Thank you very much for the help! Hope too many people are not still angry with
your Cargo Cult code after all these years.. :)
Rob
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3B14899A.127F301B@stomp.stomp.tokyo...
> Rob wrote:
>
> > I am still stuck though my friend.. :)
>
> > This works perfectly as a script through perl, but when I put it into a html
> > page, I get, for example:
> > Format One: Sun, Jan 0, 0:0 AM PST (-0800 GMT)
>
>
> Boys....
>
> Pick a format. Experiment with it. Learn, darn it.
>
>
> Godzilla!
> --
>
> #!perl
>
> print "Content-Type: text/plain\n\n";
>
> my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
>
> if ($sec < 10)
> { $sec = "0$sec"; }
> if ($min < 10)
> { $min = "0$min";}
> if ($hour < 10)
> { $hour = "0$hour"; }
> if ($mon < 10)
> { $mon = "0$mon"; }
> if ($mday < 10)
> { $mday = "0$mday"; }
>
> my ($month) = ($mon + 1);
> my ($year) = ($year + 1900);
> my ($am_pm) = "AM";
> if ($hour > 12)
> { $hour = $hour -12; $am_pm= "PM"; }
>
> my $local_timezone = "PST (-0800 GMT)";
> my (@day_of_week) = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
> my (@month) = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
> "Sep", "Oct", "Nov", "Dec");
>
>
> $date = "$day_of_week[$wday], $month[$mon] $mday, $hour:$min $am_pm
$local_timezone";
>
> print $date;
>
> print "\n\n";
>
> $date = "$day_of_week[$wday], $month[$mon] $mday, $hour:$min $am_pm";
>
> print $date;
>
> PRINTED RESULTS:
> ________________
>
> Tue, May 29, 10:44 PM PST (-0800 GMT)
>
> Tue, May 29, 10:44 PM
------------------------------
Date: Wed, 30 May 2001 05:44:07 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: use Module (if it exists)
Message-Id: <HM%Q6.86723$I5.20488639@news1.rdc1.tn.home.com>
Is there a way to say:
use String::Approx (if it's installed)
and later:
(if String::Approx is on your system) {
...
}
?
------------------------------
Date: Wed, 30 May 2001 01:11:27 -0500
From: Necro <necrorising@hotmail.com>
Subject: Web Based Email Messenger 4 is Out!!!
Message-Id: <0o39htgakvu3p4adg51e44p5722clcicbp@4ax.com>
Web Based Email
World Wide Messenger 4 Has Been Released,
Full Email System with Rich Font Text/blocking address/hundreds of
other features including a windows outlook program to retrieve and
send from your win 9X machine.
Also, we have piloted a new Alternative to PGP using public and
private keys unique to this system.
It's not quite as strong as PGP, so crackers, have mercy. Please.
But it's free.
This is all available at the
http://www.worldwidecreations.com
website
For questions/comments connect to IRC server:
irc.worldwidecreations.com
on Channel #WWC
We'll be happy to answer anyquestion or comments there in both English
and French.
Beer - WWC Staff
------------------------------
Date: Wed, 30 May 2001 05:42:48 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: what does this mean?
Message-Id: <slrn9h91el.2s4.bernard.el-hagin@gdndev25.lido-tech>
On Tue, 29 May 2001 16:55:53 GMT, Todd Smith <todd@designsouth.net> wrote:
>
>"Mark Jason Dominus" <mjd@plover.com> wrote in message
>news:3b0bbb9b.510b$1c3@news.op.net...
>> In article <slrn9gmu2s.91g.vek@pharmnl.ohout.pharmapartners.nl>,
>> Villy Kruse <vek@pharmnl.ohout.pharmapartners.nl> wrote:
>> >I wonder: why do a web search if the documentation and manuals are all
>> >installed locally?
>>
>> Why post to usenet if the manuals are all installed locally?
>>
>
>Why wash my car when it's going to rain some time in the future?
Hardly equivalent.
Cheers,
Bernard
--
perl -le '$#="Just another Perl hacker,"; print print;'
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 1017
***************************************