Show time as text E.g. 40 min ago

Discussion in 'Javascript' started by Reto, Aug 24, 2006.

  1. Reto

    Reto Guest

    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
     
    Reto, Aug 24, 2006
    #1
    1. Advertising

  2. Reto

    RobG Guest

    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
     
    RobG, Aug 24, 2006
    #2
    1. Advertising

  3. Reto

    Reto Guest

    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
     
    Reto, Aug 24, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lois
    Replies:
    1
    Views:
    3,376
    Ryan Stewart
    Dec 27, 2004
  2. juergen
    Replies:
    3
    Views:
    580
    opalinski from opalpaweb
    Sep 20, 2006
  3. Summu82
    Replies:
    5
    Views:
    892
    Richard Heathfield
    Jun 7, 2006
  4. Albert Hopkins

    When is min(a, b) != min(b, a)?

    Albert Hopkins, Jan 21, 2008, in forum: Python
    Replies:
    31
    Views:
    855
    Albert van der Horst
    Feb 4, 2008
  5. carmen

    Converting hrs and min to just min

    carmen, Aug 10, 2004, in forum: ASP General
    Replies:
    4
    Views:
    143
    carmen
    Aug 10, 2004
Loading...

Share This Page