Hi all.
I needed a "last modified" script for my website. I found this one:
# Configuration
@months = ("January","February","March","April","May","June",
"July","August","September","October","November","December"
#################################
# Executable
$ENV{"TZ"} = "CST6CDT";
# Get the input
$link = $ENV{'DOCUMENT_URI'};
$root = $ENV{'DOCUMENT_ROOT'};
if (substr($link, 1, 1) eq '/') {
$link = substr($link, 1, length($link) - 1);
}
if (substr($root, length($root), 1) eq '/') {
$root = substr($root, 0, length($root) - 1);
}
### Calculating the $date ###
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat("$root/$link"
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($mtime);
$time = sprintf("%02d",$min);
$year += 1900;
$date = "$months[$mon] $mday, $year at $hour:$time";
print "Content-Type: text/html\n\n$date";
My question is:
How do I add am/pm to the time display?
Thanks!
Daf
I needed a "last modified" script for my website. I found this one:
# Configuration
@months = ("January","February","March","April","May","June",
"July","August","September","October","November","December"
#################################
# Executable
$ENV{"TZ"} = "CST6CDT";
# Get the input
$link = $ENV{'DOCUMENT_URI'};
$root = $ENV{'DOCUMENT_ROOT'};
if (substr($link, 1, 1) eq '/') {
$link = substr($link, 1, length($link) - 1);
}
if (substr($root, length($root), 1) eq '/') {
$root = substr($root, 0, length($root) - 1);
}
### Calculating the $date ###
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat("$root/$link"
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($mtime);
$time = sprintf("%02d",$min);
$year += 1900;
$date = "$months[$mon] $mday, $year at $hour:$time";
print "Content-Type: text/html\n\n$date";
My question is:
How do I add am/pm to the time display?
Thanks!
Daf