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 9186347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:30:16+00:00 2026-06-17T19:30:16+00:00

I created a clock to be placed in the header of my website. The

  • 0

I created a clock to be placed in the header of my website. The time is not displaying a zero for minutes < 10. For example if the time is 10:50, it will only show 10:5 ,I found a solution but unsure of how to implement it. Also if there is a better method please share.

 var current;
window.onload = function () {

    current = new Date();

    document.getElementById("clock").innerHTML = current.getHours() + ":" +      current.getMinutes(); 

This is what I need

                if (minutes < 10)
                minutes = "0" + minutes

and this is the container for my clock

    <span id="clock">&nbsp</span>
  • 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-06-17T19:30:18+00:00Added an answer on June 17, 2026 at 7:30 pm

    Since you’re likely to run into presentational issues in the future along the same lines, I’d recommend picking a favorite string formatting function for Javascript.

    Some examples:

    • http://www.masterdata.se/r/string_format_for_javascript/
    • http://www.diveintojavascript.com/projects/javascript-sprintf

    Then you can do something like "{0:00}:{1:00}".format(current.getHours(), current.getMinutes()) or even better,

    var d = new Date();
    var s = d.format("hh:mm:ss tt");
    // Result: "02:28:06 PM"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I created this clock which displays Date and Time. Is there a more
I have created a custom column header renderer for my AdvancedDataGrid which has a
I have a problem with my two JList components. I created and placed on
my report has no header and footer. my report shows show data according to
I have created a binary clock and am using the willAnimateToInterfaceOrientation: duration: method to
I've successfully made JQuery work with Master Pages, but not JQuery UI.My header in
I created a custom UITableViewCell and placed a UITextView element on it. Now when
I have created a UITabbar with 3 items and placed it on a UIScrollView
I have created an ASP.NET 3.5 form page. At the top I have placed
How to set custom time to Android AnalogClock placed in app widget? As an

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.