Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6107077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:08:59+00:00 2026-05-23T14:08:59+00:00

I am looking for a simple jQuery clock. There are tonnes out there, but

  • 0

I am looking for a simple jQuery clock.

There are tonnes out there, but I am looking for one where I can set the current time, and the output format.

So I want to be able to call something like

$('#clock').clock({
  format: 'l dS F Y, h:i a',    //PHP date format, but anything that can mimic this output is good
  date:   '2012-07-01 23:59:59' //MYSQL date format, but can output as anything
});

Is there something like this (even raw js will do).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:08:59+00:00Added an answer on May 23, 2026 at 2:08 pm

    Creating a counter for a clock is pretty simple, you can probably write one in less time that it takes to review the answers you’ll get here. Below is one I made as an example of prototype inheritance.

    Just format the output however you like, add CSS to your hearts content to make it look good.

    // Create a digital clock
    // Write time in hh:mm:ss.nnn format
    // el is an element
    function Clock(el) {
      if (typeof el == 'string') el = document.getElementById(el);
      this.el = el;
    }
    
    // Clock methods
    Clock.prototype = {
      // Utilty functions
      addZ: function(n) {
        return n < 10? '0' + n : '' + n;
      },
      addZZ: function(n) {
        return n < 10? '00' + n : n < 100? '0' + n : '' + n;
      },
    
      formatTime: function(d) {
        return  this.addZ(d.getHours()) + 
          ':' + this.addZ(d.getMinutes()) +
          ':' + this.addZ(d.getSeconds()) + 
          // Milliseconds are just for debug, remove from finished version
          '.' + this.addZZ(d.getMilliseconds())
      },
    
      update: function() {
        var clock = this;
        var d = new Date();
    
        // Set next run to just after full second
        var interval = 1020 - d.getMilliseconds()
        this.el.innerHTML = this.formatTime(d);
        setTimeout(function(){
          clock.update();
        }
        ,interval);
      }
    };
    
    // Create a new clock
    // el is id or element to display text in
    function newClock(el) {
      var y = new Clock(el);
      y.update();
    }
    

    Edit

    A generic date format function: http://blog.stevenlevithan.com/archives/date-time-format

    A specific function to format a date to be like Tuesday 05th July 2011, 10:31 am:

    var formatDate = (function() {
    
      // Days of the week, zero is Sunday
      var days = ['Sunday','Monday','Tuesday','Wednesday',
                  'Thursday','Friday','Saturday'];
    
      // Months of the year, zero is January
      var months = ['January','February','March','April',
                    'May','June','July','August','September',
                    'October','November','December'];
    
      // Format single digit numbers
      function addZ(n) {
        return n<10? '0' + n : '' + n;
      }
    
      // Add ordinal to numbers
      function addOrdinal(n) {
        return ['th','st','nd','rd'][(''+n).slice(-1)] || 'th';
      }
    
      return function (date) {
        var d = addZ(date.getDate());
        var h = date.getHours();
        var ap = h < 12? 'am' : 'pm';
            h = addZ(h > 12? h - 12 : h);
    
        return days[date.getDay()] + ' '
          + d + addOrdinal(d)  + ' '
          + months[date.getMonth()] + ' '
          + date.getFullYear() + ', '
          + h + ':'
          + addZ(date.getMinutes()) + ' '
          + ap
      }
    }());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok this has got to be a stupid simple one, but I just can't
Ok, this is an embarassingly simple-looking problem, but is driving me crazy. I'm learning
I am looking for a simple unpatented one-way encryption algorithm, preferably in c. I
I'm looking to create a wrapper control for JQuery date time picker control to
I have written this simple bit of jQuery that swaps out the containing ul's
I have an html select: <select> <option>Choose one</option> </select> Using jQuery, is there an
I am looking for a simple jQuery carousel example(s) that does not require a
I have spent the last two days looking for a simple javascript or jquery
please be easy - first post! Looking to modify the following script: http://jonraasch.com/blog/a-simple-jquery-slideshow Love
I'm looking to create a simple jquery game. It starts like this, the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.