Date/Time

They have: 850 posts

Joined: Jul 1999

Does anyone have a Date/Time script they could post that gets the date and time on the server with a nice formated output? I want the output to look like this

6:59 PM Est, December 19, 1999

Thanks.

------------------
An ostrich's eye is bigger than it's brain.

They have: 1,587 posts

Joined: Mar 1999

i've got one that does it, but in military time and no am/pm. if interested let me know.

------------------
Get paid to surf, email, and everything else online! 75 hrs a month at 55+ cents an hour! Beats AllAdvantage Easily. CLICK 4 DETAILS

Traffic-Website.com free traffic, affiliate programs, hosting, & domain names.
My Site got hacked, but i'm coming back?

They have: 850 posts

Joined: Jul 1999

If you could post it that would be great thanks.

------------------
An ostrich's eye is bigger than it's brain.

They have: 1,587 posts

Joined: Mar 1999

hope it helps!

Code Sample:

sub clock {
($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";
}

$month = ($mon + 1);
@months = ("January","February","March","April","May","June","July","August","September","October","November","December");
$date = "$hour\:$min\:$sec $month/$mday/$year";
}

------------------
Get paid to surf, email, and everything else online! 75 hrs a month at 55+ cents an hour! Beats AllAdvantage Easily. CLICK 4 DETAILS

Traffic-Website.com free traffic, affiliate programs, hosting, & domain names.
My Site got hacked, but i'm coming back?

They have: 161 posts

Joined: Dec 1999

NO!!!! Fairhousing, NOW would be a good time
to check that all of your Perl programs are
Y2K compliant.

The value of the year that localtime returns
is the year - 1900. So next year, it will
return the number 100.

Your program would print the date as
something like "01/01/100" instead of
"01/01/00". Please consider a fix (such as
$year %= 100). Also, the only proper way to
restore the ACTUAL year is to add 1900.
Nothing else.

As for code to print the date in your pretty
format, I suggest this... oh, I don't know
the NAMES of all 24 time zones (there's some
research for someone to do) and you didn't
say if you want the number of the day
0-padded (I assumed not). I'll explain how
the @tz array must be filled below.

Code Sample:

sub myfmt {
  my @mon = qw(
    January February March April May June
    July September October November December
  );
  my @tz = qw( ); # fill this appropriately
  my ($min,$h,$m,$d,$y) = (localtime)[1..5];
  my $offset = $h - (gmtime)[2];
  my $mode = "AM";

  if ($h == 0) { $hr = 12 }
  elsif ($h == 12) { $mode = "PM" }
  elsif ($h > 12) { $h -= 12; $mode = "PM" }

  sprintf "%d:%02d %s %s, %s, %d, %d",
    $h, $min, $mode, $tz[$offset], $mon[$m],
    $d, $y + 1900;
}

Now let me explain how the @tz array should
be filled. We know that EST is GMT -5 hours,
so $offset would be the number -5.
Therefore, in this array of 24 strings,
element 0 would be "GMT" and element -5 would
be "EST". Translating the negative notation
for positive notation, we get element 19
being "EST".

Hope this helps.

------------------
--
MIDN 4/C PINYAN, NROTCURPI, US Naval Reserve

[This message has been edited by japhy (edited 21 December 1999).]

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.