You are here: Re: How to display time and date: « HTML « IT news, forums, messages
Re: How to display time and date:

Posted by Toby Inkster on 11/24/46 11:45

Captain Dondo wrote:

> Given these limitations, is there a way to show a real-time, ticking
> clock?

Ah -- only just read that.

If you can afford to be a handful of seconds inaccurate, you could use PHP
to generate some Javascript like:

<script type="text/javascript">

var servertime = new Date('<?= htmlentities(date('r')) ?>');
var clienttime = new Date();
var timeoffset = servertime - clienttime;

function alertDate ()
{
var d = new Date();
d += timeoffset;
window.alert('The server date is ' + d.toString());
}

var annoyance = window.setInterval('alertDate', 20000);

</script>

That's not been tested, so it may have one or two syntax errors, but it
should give you an idea about how to proceed.

(I felt I owed you a good answer after my previous rubbish one!)

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация