Time/Date Getter/Formatter by Jeff Davis This script is designed to be used at the top of another perl script, but below the "#!perl_path_here" statement (If you don't know what it is, it tells the script where the perl program is). If you are not adding on to another script you will need to add that line in yourself, like this: #!/usr/bin/perl where /usr/bin/perl is the directory on the server where perl is. You will want to use this to get the date off of the server and then you can format it exactly as you wish. You can have it display anything from "Sunday, October 12 at 12:22 pm" to "11/2/98 @13:52:12". You can make any combinations. The numbers/words that the script will get for you are here: -hour of time, by 12 hour clock -hour of time, by 24 hour clock -minute of time -second of time -day of the week (monday, tuesday, etc.) -day of the month (the number part in this example: "May 21st") -last 2 digits of year (i.e. "98") -month in number form -month in word form -am or pm variable, changes with time of day. works even with 24 hour time. **** There is also an "hour change factor" which changes the time from the server time you get (more detail below). remeber, there are infinite (close at least) possibilities. Format this any way you want using a combination of those variables. The exact setup instuctions with exact variables are below. ------- How to setup I. Find the change variable, written as "$change". A. Found below the part that says "SET THIS:" B. Followed by an "=" II. Change the variable to suit your needs A. Change the zero the the number of hours your server is different from what you want the time output to be. Can be a positive or negative number. 1. Set to a negative number if you want it to subtract hours, and positive if you want it to add hours. III. Go all the way down, near the bottom, where it says "### Use these variables", and it should list off some variables, all beginning with "$". A. In perl, a "#" is used to make the program ignore the rest of the line. Ignore these marks, they are not part of the syntax. B. Remember where to fin these variables, they are what you will need to use later. IV. Go down a little, and look for the part that looks something like this: $date = "enter_your_date_format_here"; A. Replace the "enter_your_date_format_here" part with the various variables in the order you want them to be in. 1. Note that you can use extra characters in there, even html. Do not use any of the characters in the line I will put below, unless you preceed it with a backslash ( \ ). V. Dont use the following characters, without preceeding it by a backslash ( \ ): " ' : @ = $ ; } { ( ) - + | \ & * # VI. If you do not wish to have the script print the date/time for you, delete, or "comment out" these two lines: print "content-type: text/html\n\n"; print "$date"; which are found below the place you enter the format for the time/date. VII. List of variables: ------------------------ # $dayOfWeek = day of the week # $monthOfYear = month of the year (word form) # $dayOfMonth = day of the month # $year = year of the century # $monthOfYearNum = month of the year (number form) # $hour = hour for 24 hour clock # $bHour = hour for 12 hour clock # $min = minutes # $sec = seconds # $ampm = am or pm, depending on the time of day, works even with 24 hour time if you want it to. -------------------------- To set it up: if you are adding it to another script, just put it a the *top*, but below the part that tells the directory of perl. if you are using it stand alone, add this line to the top of the script: #! /usr/bin/perl where usr/bin/perl is the directory on the server where perl is. This is an example of the most common type of path, UNIX. When uploading the script, make sure to upload it ASCII, with an ftp program. You're done.