The world's biggest problem? I hope that's not true.
Next time you post, please put your code in code tags, such as [code]A bunch of code[/code]. Furthermore, in order to answer your question, code isn't really needed. Now, to answer your question...
There isn't a way to get the client time unless the client tells you what the time is on their system. Since there isn't a way to force the client to send the current time on the machine with it's request header, you'll have to find a different way to get that information. I recommend using Javascript.
There are two different ways to use Javascript to get the current time on the page: have it pass the time as part of the URL string or have Javascript print the time on the page itself. Each method has it's strengths and weeknesses. Passing the time as a URL encoded variable allows you to do fancy stuff with the time in Perl before printing the page but the time on the page will reflect that time that the page with the link was loaded, not when the current page was generated. Having Javascript on the page allows the time to be current and could automatically update the time dynamically but results in there being no purpose to the page being generated by Perl (in other words, a standard HTML page could do the exact same thing).
The following is a complete HTML page that will show the current time (see it here ):
<html>
<head><title>Current time</title></head>
<body>
<script language="JavaScript">
<!--
time = new Date();
minutes = time.getMinutes();
if(minutes < 10)
{
minutes = "0" + minutes;
}
seconds = time.getSeconds();
if(seconds < 10)
{
seconds = "0" + seconds;
}
document.write("Current time: ", time.getHours(), ":", minutes, ":", seconds);
-->
</script>
</body>
</html>
Notice that this did not require any Perl code.
The following HTML page uses Javascript to create a link that will link to a program that will use the passed in time as part of the page generation (see it here ):
<html>
<head><title>Current time</title></head>
<body>
<script language="JavaScript">
<!--
time = new Date();
minutes = time.getMinutes();
if(minutes < 10)
{
minutes = "0" + minutes;
}
seconds = time.getSeconds();
if(seconds < 10)
{
seconds = "0" + seconds;
}
document.write('<a href="/cgi-bin/showClientTime.cgi?time=', time.getHours(), ":", minutes, ":", seconds, '">Show Time</a>');
-->
</script>
</body>
</html>
The code I used in showClientTime.cgi is really simple and simply returns the time in a plain text format.
#!/usr/bin/perl
use strict;
use CGI;
my %FORM;
my $query = new CGI;
foreach my $key (sort {$a <=> $b} $query->param())
{
$FORM{$key} = $query->param($key);
}
print "content-type: text/plain\n\n";
print $FORM{'time'};
exit;
I would recommend just using Javascript for your problem. The times when you want to use passed Javascript URL-encoded variables is when you are generating an image. Using passed variables and image generating code, you can have images that show the current client time on the page.
Does that help you at all?