Forum Moderators: open

Message Too Old, No Replies

To auto enter date and time

         

Dexie

9:11 am on Jul 11, 2005 (gmt 0)

10+ Year Member



Anyone know if there's a way to have the date and time automatically enter on a page, without javascript please?

BlobFisk

9:27 am on Jul 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Dexie,

You can do this at the server side using a server side language. But for a pure client side solution you need to use a scripting language like JavaScript.

HTH

Alioc

10:45 am on Jul 11, 2005 (gmt 0)

10+ Year Member



Use SSI to display server time. You can manipulate the time with some cgi or php scripting (+- hours) and include the script output to your pages.

Dexie

11:02 am on Jul 11, 2005 (gmt 0)

10+ Year Member



Many thanks to you both for your input - it's appreciated.

Which way is better for this application please - php or cgi?

Alioc

12:31 pm on Jul 11, 2005 (gmt 0)

10+ Year Member



Whichever you find. That's very basic scripting so it doesn't make sense to prefer one to another. I sent you a link. Check your sticky mail. It's an example of what can be done.

encyclo

12:50 pm on Jul 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As Alioc says, you can use any server-side scripting language to display a timestamp, so your choice depends on other factors and what other dynamic elements you want to use on your page.

One important detail: a timestamp generated server-side displays the time as set on your server, which might not correspond to the time zone your visitor is in. Using Javascript will display the time the same as the user's clock.

It is important to note that nearly every computer has a clock displaying permanently in the taskbar (whatever the operating system), so you should ask yourself whether the date and time displayed on your page are really necessary or if they would just be a distraction. You might find a better use for that valuable screen real estate. :)

Dexie

12:56 pm on Jul 11, 2005 (gmt 0)

10+ Year Member



Many thanks for the link, that did give me more info and I have Googled this, but can't seem to find the solution - I'll explain what I'm looking for.

A server side solution that would show the date and time, *but* to the *last* half-hour, so, if you looked at the page at 14.55 today, it would show as Monday, the 11th of July at 14.30 - another example, if it helps, if you looked at the page this Thursday at 15.10, it would say Thursday, the 14th of July at 15.00

If you need any more info, just holler.

Any help appreciated.

Dexie.

Dexie

1:50 pm on Jul 11, 2005 (gmt 0)

10+ Year Member



Many thanks Encyclo, I think my post above may have crossed with yours ;-) The date and time is relevant to the text on the page, and will, because of the context, enhance the page.

Now that I've explained above, whats needed, would cgi, perl or php still be equally as good as each other? If so, are they all easy as each other to implement please?

Dexie.

encyclo

2:25 pm on Jul 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Like I said, the server-side scripting language are all capable. One of the easiest to implement is PHP, and you can just add the PHP code inline within the HTML document rather than having to generate the whole page out of script. PHP is very widely-supported too on both Unix and Windows servers.

You should look at the PHP date function [ca.php.net] - you can start with something like:

<?php echo date("F j, Y, g:i a");?>

The "i" represents the minutes - if you want to have the time to the previous hour only you can try replacing "i" with "00" - otherwise you will need to check the value of the minutes and display "00" or "30" as required.

You might want to check out the PHP Server Side Scripting [webmasterworld.com] forum to learn more about PHP. :)

Dexie

6:33 pm on Jul 11, 2005 (gmt 0)

10+ Year Member



Many thanks Encyclo, have now, after a few hours finally got the code done, but have now hit another problem - I'll post further on the php forum.

Where's the edit option on these boards? There used to be an edit option, didn't there?

tedster

7:28 pm on Jul 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



An edit option does appear on the left, but only for a short time after your original post. The exact time interval varies according to our propietary formula ;)