View Full Version : Looking for Date/Time JavaScript?
Patrick
09-28-2000, 09:31 AM
I'm looking for a simple script to paste into a cgi script that will display the time and date of the FQ servers. Something like this:
Thursday, September 28th, 2000 @ 9:25am EST
Example, when one of my users go to the page that has the cgi script I need to add to the script that displays the time and day that it is.
Thanks for any help.[nbsp]
wolfstalks
09-28-2000, 09:46 AM
Patrick here are a couple of instant code generators that work on our sites here at "FQ", you might find what you're looking for here
http://www.aota.net/Pre-Installed_Scripts/autoclock.php3
http://www.aota.net/Pre-Installed_Scripts/autodate.php3
Hope this helps point you in the right direction?
Have a Good One
Bob
You may also find that SSI could do the trick..
Reference: http://www.aota.net/HTML/ssi.php3
But I think what you are looking for is something like:
#!/usr/bin/perl
$Date=`/bin/date`;
chomp($Date);
print <<"EOT";
Content-type: text/html
<html>
<head>
<title>Hello world</title>
</head>
<body>
<H1>Hello World</H1>
Testscript</p>
The time is now: $Date</p>
</body>
</html>
EOT
Deb
[nbsp]- Typical programmer wannabe. That's Me!
Patrick
09-28-2000, 11:41 AM
No.
I need something I can paste into a existing perl script.
Can not put ssi into the cgi script.
I want the date/time to just be text and not a graphic.
Hope this helps in further explaining my need.
Dan Kaplan
09-28-2000, 11:53 AM
Taken from Gossamer Threads' (http://www.gossamer-threads.com) free Greeting script (which I cannot find on their site anymore):
my ($time) = &get_date;
print qq~ $time ~;[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]
exit;
sub get_date {
# --------------------------------------------------------------
[nbsp][nbsp] my @days = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Sat urday');
[nbsp][nbsp] my @months = ('January','February','March','April','May','June','July',
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]'August','September','October','November','December');
[nbsp][nbsp] my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
[nbsp][nbsp] ($hour < 10) and ($hour = "0$hour");
[nbsp][nbsp] ($min < 10)[nbsp][nbsp]and ($min = "0$min");
[nbsp][nbsp] ($sec < 10)[nbsp][nbsp]and ($sec = "0$sec");
[nbsp][nbsp] my $date = "$days[$wday] $months[$mon] $mday";
[nbsp][nbsp] ($hour < 12)[nbsp][nbsp]and ($noon = "am");
[nbsp][nbsp] ($hour > 12)[nbsp][nbsp]and ($hour = $hour - 12) and ($noon = "pm");
[nbsp][nbsp] ($hour == 00) and ($hour = 12);
[nbsp][nbsp] ($hour == 12) and ($noon = "pm");
[nbsp][nbsp] return "$hour\:$min $noon on $days[$wday], $months[$mon] $mday";
}
I think I removed all the non-time/date items.
Date
edit:[nbsp][nbsp]might as well take out the time zone correction for my location...
[This message has been edited by Dan Kaplan (edited 09-28-00@11:54 am)]
Dan Kaplan
09-28-2000, 03:35 PM
You still need the subroutine, as that's what assigns the date/time values to the variable.[nbsp][nbsp]Notice the line:
my ($time) = &get_date;
Wherever you place the output with $time, you would place HTML formatting around it just like it was text.
Dan
Patrick
09-28-2000, 04:26 PM
Thanks, I'll give it a try 2nite. I just copy and paste the above code anywhere into my existing script, or does it need to be in a certain place?
[This message has been edited by Patrick (edited 09-28-00@4:28 pm)]
Dan Kaplan
09-28-2000, 04:59 PM
Place it after the last subroutine in the script, although pretty much anywhere will work (assuming variables and the like don't interfere with other aspects of the script).
Dan
WayneK
09-28-2000, 05:09 PM
I'm looking for a simple script to paste into a cgi script that will display the time and date of the FQ servers.
Javascript can only print the clients date and time.
<SCRIPT>
document.write(Date()+".")
</SCRIPT>
[This message has been edited by WayneK (edited 09-28-00@5:10 pm)]
Patrick
09-29-2000, 12:37 AM
I try again.
The script must be able to be pasted in the html part of my cgi script.
That's way I thought a Java script would be better?
Dan Kaplan
09-29-2000, 12:45 AM
Just paste $time wherever you want it in your HTML section, and it should work fine.[nbsp][nbsp]It simply passes the time/date info through a variable.
Dan
Patrick
09-29-2000, 12:54 AM
Just $time?
No need for the other code. How do I control the appearance of what it looks like in html?
vBulletin® v3.6.8, Copyright ©2000-2013, Jelsoft Enterprises Ltd.