SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: ellapsed time

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2008
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ellapsed time

    hi there

    I've find a script which take's the server time using a php function, but i need to improve it in order to compute also the elapsed time between current time and other variable in same time format.

    How to do that?

    the example I'm talking about is at address h*tp://javascriptkit.com/script/script2/servertime.shtml

  2. #2
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The timestamp obtained by PHP's mktime function is in seconds. The timestamp obtained from JavaScript's Date.getTime method is in milliseconds. So multiply the PHP timestamp by 1000 before performing mathematical operations with it in JavaScript.

    Code:
    var then = <?php echo mktime(); ?> * 1000;
    var now = Date.getTime();
    var elapsed = now - then;


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •