Today I was trying to update a clock on a page I am building using ror. My first attempt led me to this:

var setTime=function(){
d = new Date();
document.getElementById('time').innerHTML = (d.getHours() + ':' + (d.getMinutes() d.getMinutes()) + ':' + d.getSeconds() + ' on ' + ['January', 'February',
'March', 'April', 'May', 'June', 'July', 'August', 'September',
'October', 'November', 'December'][d.getMonth()] + ' ' + d.getDate() +
', ' + d.getFullYear())
new PeriodicalExecuter(setTime, 1);

Which updates the time, but its system time, not server time.

So I then tried this more railsy way:

periodically_call_remote(:url => {:action => 'get_time'}, :frequency => '5', :update => 'time')


def get_time
render :text =>'%H:%M:%S on %a %b %d, %Y')

This works, but it hits the server for the time every :frequency... Still searching for something better.

Thanks to the guys in my ruby group for getting me this far. (google groups, tulsarb)