Similar to the Date being entered automatically, is there a way to have a time field also ?
Jan 13, 1999, 6:36 AM
Novice (21 posts)
Jan 13, 1999, 6:36 AM
Post #4 of 7
Views: 2818
Hi guys,
I've got a little mod if you don't like the current 24 hour format of &get_time. Try the following:
my ($AMPM);
my (@hours) = qw!12 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11!;
if ($hour < 12) { $AMPM = "am"; } else { $AMPM = "pm"; }
Then replace:
return "$hour:$min";
with
return "$hours[$hour]:$min $AMPM";
I haven't encountered any problems with it so far, but if you see anything that could cause a problem then please post here.
I've got a little mod if you don't like the current 24 hour format of &get_time. Try the following:
my ($AMPM);
my (@hours) = qw!12 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11!;
if ($hour < 12) { $AMPM = "am"; } else { $AMPM = "pm"; }
Then replace:
return "$hour:$min";
with
return "$hours[$hour]:$min $AMPM";
I haven't encountered any problems with it so far, but if you see anything that could cause a problem then please post here.
Feb 12, 1999, 1:53 AM
Novice (44 posts)
Feb 12, 1999, 1:53 AM
Post #6 of 7
Views: 2815
Open db.cgi, locate the get_time subroutine, and add the "my" statements before the existing one.
Then, in the same sub, make the change to the display of the time.
So what was
# --------------------------------------------------------
# Returns the time in the format "hh-mm-ss".
#
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(time());
($sec < 10) and ($sec = "0$sec");
($min < 10) and ($min = "0$min");
($hour < 10) and ($hour = "0$hour");
return "$hour:$min:$sec";
}
Is now
# --------------------------------------------------------
# Returns the time in the format "hh-mm-ss".
#
my ($AMPM);
my (@hours) = qw!12 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11!;
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(time());
if ($hour < 12) { $AMPM = "am"; } else { $AMPM = "pm"; }
($sec < 10) and ($sec = "0$sec");
($min < 10) and ($min = "0$min");
($hour < 10) and ($hour = "0$hour");
return "$hours[$hour]:$min $AMPM";
}
You could leave the seconds display in after the $min if you wanted.
Hope that's right -- it's what worked for me!
[This message has been edited by Glen Payne (edited February 12, 1999).]
Then, in the same sub, make the change to the display of the time.
So what was
Code:
sub get_time { # --------------------------------------------------------
# Returns the time in the format "hh-mm-ss".
#
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(time());
($sec < 10) and ($sec = "0$sec");
($min < 10) and ($min = "0$min");
($hour < 10) and ($hour = "0$hour");
return "$hour:$min:$sec";
}
Is now
Code:
sub get_time { # --------------------------------------------------------
# Returns the time in the format "hh-mm-ss".
#
my ($AMPM);
my (@hours) = qw!12 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11!;
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(time());
if ($hour < 12) { $AMPM = "am"; } else { $AMPM = "pm"; }
($sec < 10) and ($sec = "0$sec");
($min < 10) and ($min = "0$min");
($hour < 10) and ($hour = "0$hour");
return "$hours[$hour]:$min $AMPM";
}
You could leave the seconds display in after the $min if you wanted.
Hope that's right -- it's what worked for me!
[This message has been edited by Glen Payne (edited February 12, 1999).]