Results 1 to 3 of 3

Thread: [RESOLVED] How to show time using javascript?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2018

    Resolved [RESOLVED] How to show time using javascript?

    Hi folks,

    How to show time on my page [Hours:Minutes:Seconds am/pm] similar to this
    03:09:02 PM

    Thank you for your time very much. Any help will be appreciated.

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004

    Re: How to show time using javascript?

    I get time like this.

    // Create a random name for the print frame.
    var strFrameName = ("printer-" + (new Date()).getTime());
    You would need to examine the string returned and cut if up (unless the GETTIME method has a format parameter - you would need to google that.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3
    King of sapila
    Join Date
    Oct 2006

    Re: How to show time using javascript?

    Your server time or the client time?
    Date will show the client time. You can also customize the time see: https://developer.mozilla.org/en-US/...esolvedOptions
    You may be able to hit a free service to get back time with options.
    You can also show server time. Here is some code i found with Jquery that szlamany fancy so much (not tested)
    function getServerTime() {
      return $.ajax({async: false}).getResponseHeader( 'Date' );
    console.log('Server Time: ', getServerTime());
    console.log('Locale Time: ', new Date(getServerTime()));
    Slow as hell.

Posting Permissions

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


Click Here to Expand Forum to Full Width