Forum Moderators: open

Message Too Old, No Replies

Date field in <head>tag

Is there another way to do this?

         

Daily Sparring

1:05 pm on May 7, 2004 (gmt 0)

10+ Year Member



I want to display the date in the <head> tag and I would like the date to remain correct. Is there a way to do this without javascript? If so could someone please help me?

<head>My site name: 05/07/2004 </head>

tomorrow should change to

<head>My site name: 05/08/2004 </head>

My pages are all html and I would like to keep them that way, but I may have to make the switch. I tried a javascript date but whenever I checked Google for a cached page the javascript updated, so it was an old page view but todays date. I hope I am making sense.

choster

1:20 pm on May 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Javascript dates are calculated based on the system time of the user agent (browser) at the moment the script is processed.

If you want the date to be a proper "stamp," you'd have to insert it on the server side using SSI or one of the dynamic technologies (ASP, PHP, CF, JSP, etc.).

For instance, if your host permits server-side includes, you could add

<html>
<head>
<!-- formats date as mm/dd/yyyy with leading zeros -->
<!--#config timefmt="%m/%d/%Y"-->

<!-- outputs the current date -->
<title>My Site Name: <!--#echo var="DATE_LOCAL" --></title>
</head>
[...]

Daily Sparring

2:10 pm on May 7, 2004 (gmt 0)

10+ Year Member



Thanks,

My host does allow for SSI, but would that mean I would have to change my home page to .php etc...
I was wondering if there was a way to date stamp using .html pages. I know I have seen .html pages with a date stamp that are cached showing different dates, but I don't know how they are able to keep the .html extension.

bruhaha

2:35 pm on May 7, 2004 (gmt 0)

10+ Year Member



I have seen .html pages with a date stamp that are cached showing different dates, but I don't know how they are able to keep the .html extension.

Actually, it's quite simple. You can write you own .htaccess file (if your sever permits you, of course!) and include a list of the extensions you wish to accept SSI. (Downside: this setting will slow down the serving of pages, since it tells the server to check every one of these pages for includes.)

mincklerstraat

1:07 pm on May 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Another option, a bit more difficult, would be to use Apache's mod_rewrite to make your php pages appear as html pages. That way, only the ones that really need php parsing are php parsed.