Show time as text E.g. 40 min ago

R

Reto

Hi,

Many web sites e.g. Writely show when the document was last changed.
Has anybody a javascript which converts a date time stamp into such a
textual representation?

Thanks,
Reto
www.xcellery.com
 
R

RobG

Reto said:
Hi,

Many web sites e.g. Writely show when the document was last changed.
Has anybody a javascript which converts a date time stamp into such a
textual representation?

It seems to me that that type of functionality should be done on the
server. If you use JavaScript and the client system date/time, you are
hoping that the clocks are reasonably synchronised. You also have to
ensure that the two timestamps are reduced to a common datum before
calcuating the difference.

If you try to avoid those issues by sending a current timestamp from
the server in addition to the timestamp for the document and then use
script to calculate the difference client-side, you might as well do
the maths on the server and just send the time difference.

If you want to go ahead with a JavaScript solution, pretty much
everything you need is here:

<URL: http://www.merlyn.demon.co.uk/js-date0.htm >
 
R

Reto

Thanks Rob,

Yes you are probably right. It's better to compute this on the server
side in order to base it on the same time reference which will be the
server.

Thx,
Reto
www.xcellery.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top