Gossamer Forum
Home : Products : DBMan : Installation :

Is it possible to have a Time Field ?

Quote Reply
Is it possible to have a Time Field ?
Similar to the Date being entered automatically, is there a way to have a time field also ?
Quote Reply
Re: Is it possible to have a Time Field ? In reply to
Hi Katana,

Have you tried calling the get_time sub (in db.cgi)?

cheers
-JO
Quote Reply
Re: Is it possible to have a Time Field ? In reply to
Wehoo! How easy !
Quote Reply
Re: Is it possible to have a Time Field ? In reply to
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.
Quote Reply
Re: Is it possible to have a Time Field ? In reply to
This sounds great, where do i put this code? before here and after there? Wink
Quote Reply
Re: Is it possible to have a Time Field ? In reply to
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
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).]
Quote Reply
Re: Is it possible to have a Time Field ? In reply to
Can this some how be used in date comparisons? What would you type a field with time in it?