|
Can Server-Side Includes (SSI) Produce Date or Time Output?
The question arose: "I'm always forgetting to change the copyright notices on the bottom of my Web pages, so it's not uncommon for me to have 2003 as the copyright well into 2004, and I'm sure that I'll do the same thing in 2005. Help! Surely there's some easy SSI trick for fixing this?"
I talk about some of these capabilities in my book Creating Cool Web Sites with HTML, XHTML and CSS, but rather than do that annoying Time-Life ad bit of "buy the book!" I'll just answer the question, okay? :-) There's a helpful directive in SSI called echo which can produce the date and time on your page without any JavaScript and without any CGI programming. It'd look like this: <!--#echo var="DATE_LOCAL" -->Mildly interesting, right? Here's what happens on this page when the directive is expanded: If you use the config option beforehand, you can actually create any timestring you want exactly as you can pass date and time format strings as an argument in Unix's date command! So here's the answer to your question: <!--#config timefmt="%Y" --> <!--#echo var="DATE_LOCAL" -->And here's its output: . Cool stuff, eh? You can easily imagine an always up-to-date copyright notice now, can't you? There are a number of different references online that give much more detail about the timefmt string, but here's the one I've found the clearest: Indiana University's Webmaster SSI Tutorial. Oh! If you're using PHP, don't forget that you can accomplish the same trick by using: <?echo date('Y');?>
Hope that helps you out!
Categorized:
HTML and CSS
(Article 3759,
Written by Dave Taylor)
Tagged: Previous: How do I change my Mac OS X hard drive icon? Next: Are there any hidden dangers lurking in Firefox 1.0? Subscribe!
Rather amazingly, there are no comments on this article yet.
I have something to say, now that you mention it, but ...
I do have a comment, now that you mention it!
|
Recommended
Recent Entries
Search
I Need Help!
Apple iPad Help
Articles and Reviews Auctions and Online Shopping Blogs and RSS Feeds Building Web Site Traffic Business and Management CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above Facebook Help Google Plus Help HTML and CSS Industry News and Trade Shows iPhone and Cell Phone Help iPod, Sony PSP and MP3 Player Help Mac OS X Help Pay Per Click (PPC) Advertising Search Engine Optimization (SEO) Shell Script Programming Tech Support Video Help The Writing Business Twitter, LinkedIn and Social Network Help Unix and Linux Help Video Game Tips and Help Windows PC Help WordPress Help |