bw-datetime
This is a simple "include script" for displaying the date and time
on a web page. It is run from a server-side include (SSI).
On an Apache server you put something like this in your page:
<!--#include virtual="/bw-datetime/bw-datetime.cgi" -->
The result should be something like this:
12:35 pm on Friday, 6 December 2024 in Las Vegas, Nevada
Of course you can modify the text at the bottom of the script.
Here is the source code for bw-datetime.cgi. Copy/paste this code into your
text editor, and make sure that the line
#!/usr/bin/perl -w
is the first line in the file.
#!/usr/bin/perl -w
#
# bw-datetime.cgi
#
# Show the date and time on a web page.
#
# Copyright 2003 by Bill Weinman [http://bw.org/]
#
# The author grants permission to use and modify this program as you like.
# All other rights and ownership are reserved by the author.
#
use strict;
print "Content-Type: text/html\n\n";
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
my @days = qw(
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
);
my @months = qw (
January February March April May June July
August September October November December
);
my $dayofweek = $days[$wday];
my $month = $months[$mon];
$year = $year + 1900;
my $meridian = ($hour > 11) ? "pm" : "am";
my $hours = ($hour > 12) ? ($hour - 12) : $hour;
my $minutes = sprintf("%02d", $min);
my $seconds = sprintf("%02d", $sec);
print
"${hours}:${minutes} ${meridian} " .
"on ${dayofweek}, ${mday} ${month} ${year} " .
"in Las Vegas, Nevada\n";
exit;
|