
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: Friday, 04-Jul-2008 14:25:42 MDT 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: 2008 . 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!
Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Simpy.
Categorized:
HTML and CSS
(Article 3759)
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!
Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.
Rather amazingly, there are no comments on this article yet.
I have a lot to say, but ...
I do have a comment, now that you mention it!
|
![]()
Search
Find just the answers you seek from among our 1700+ free tech support articles by using our Lijit search engine.
Help!
Subscribe to
Ask Dave Taylor!
Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.
Articles and Reviews
Auctions and Online Shopping Blogs and RSS Feeds Building Web site traffic Business and Management Cell Phones and Mobile Phones CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above HTML and CSS Mac OS X Help MySpace, Facebook, Twitter and Social Network Help Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Help Video Game Tips and Help Windows Help
Recent Entries
Join the List!
Book Links
|