Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Show time as text E.g. 40 min ago

Reply
Thread Tools

Show time as text E.g. 40 min ago

 
 
Reto
Guest
Posts: n/a
 
      08-23-2006
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

 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      08-24-2006

Reto wrote:
> 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 >


--
Rob

 
Reply With Quote
 
 
 
 
Reto
Guest
Posts: n/a
 
      08-24-2006
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

RobG wrote:
> Reto wrote:
> > 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 >
>
>
> --
> Rob


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When is min(a, b) != min(b, a)? Albert Hopkins Python 31 02-04-2008 07:37 PM
How to write min(a,b) instead of Math.min(a,b) juergen Java 3 09-20-2006 04:20 AM
covert time from date Hour min sec format to epoch time i.e time since 1 jan 1970 in C Summu82 C Programming 5 06-07-2006 02:51 PM
CSS min-width, max-width, and min-height with display:inline Lois HTML 1 12-27-2004 03:03 AM
Converting hrs and min to just min carmen ASP General 4 08-10-2004 08:31 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57