The year day number is the number of days counted from January 1 of the year in question.
January 1 is year day 1. February 10 is year day 39. And so forth.
Some reasons for printing the year day on web pages:
For the novelty of it. Because you can.
To nudge toward a sale. Mention the year day and ask why they haven't bought their widget yet.
"It's day
my, how this year has flown!"
Printing the Year Day on a Web Page
Printing the year day on a web page can be done with SSI or with JavaScript.
Printing the Year Day on a Web Page with SSI
To print the year day on a web page with SSI requires that your web page has the .shtml or other extension your hosting company has deterimined for SSI.
The localtime function without parameters returns an array of numbers relating to the current second of time according to the server's clock. Array element 7 contains the current year day number.
To install the script:
Copy the above and paste it into a plain text word processor like NotePad or BBEdit.
Verify the first line of the script has the directory location of perl on your server.
Save it, giving it a file name like yearday.cgi or yearday.pl (depending on which file name extension your server uses to run perl CGI scripts).
Upload it to your server in a location that can run perl CGI scripts.
Give the script 755 permissions.
Then, on the web page where the current year day shall be printed, put this SSI tag:
Change the URL in the SSI tag to the relative URL of the script.
If your hosting company doesn't allow the SSI #exec tag, you can try this one (which might or might not work, depending on how your hosting company has SSI configured on the server):
Printing the Year Day on a Web Page with JavaScript
An alternative to SSI is with JavaScript/Perl combination.
First install this perl script:
Then, on the web page where the current year day shall be printed, put this JavaScript:
Change the URL in the SSI tag to either the relative URL or the absolute http://... URL of the script.
Question:
Did you find this article interesting and understandable? How can it be improved?
Your response is anonymous.
When done typing, click anywhere outside the box. [more info]