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

  • Home
  • SEARCH
  • 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 899093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:09:36+00:00 2026-05-15T15:09:36+00:00

Basically this script will subtract StartTime from EndTime, using a jQuery plugin the html

  • 0

Basically this script will subtract StartTime from EndTime, using a jQuery plugin the html form is populated with Start and End Time in the format HH:MM, an input field is populated with the result, it works except for one issue:

If Start Time is between 08:00 and 09:59 it just returns strange results – results are 10 hours off to be precise, why?

All other inputs calculate properly!

function setValue() { 
var startTime = document.getElementById('ToilA'); 
var endTime = document.getElementById('EndHours'); startTime = startTime.value.split(":"); 
var startHour = parseInt(startTime[0]); 
var startMinutes = parseInt(startTime[1]); 
endTime = endTime.value.split(":"); 
var endHour = parseInt(endTime[0]); 
var endMinutes = parseInt(endTime[1]); 
//var hours, minutes; 
var today = new Date(); 
var time1 = new Date(2000, 01, 01, startHour, startMinutes, 0); 
var time2 = new Date(2000, 01, 01, endHour, endMinutes, 0); var milliSecs = (time2 - time1); 
msSecs = (1000); 
msMins = (msSecs * 60); 
msHours = (msMins * 60); 
numHours = Math.floor(milliSecs/msHours); 
numMins = Math.floor((milliSecs - (numHours * msHours)) / msMins); 
numSecs = Math.floor((milliSecs - (numHours * msHours) - (numMins * msMins))/ msSecs); numSecs = "0" + numSecs; numMins = "0" + numMins; DateCalc = (numHours + ":" + numMins); 

document.getElementById('CalculateHours').value = DateCalc; }
  • 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-15T15:09:36+00:00Added an answer on May 15, 2026 at 3:09 pm

    Whenever you have math problems with the number 8, it’s something getting converted into the octal system 🙂

    Numbers starting with 0 are interpreted as octal numbers in Javascript.

    It’s no problem from 01..07, because they are the same in both systems.

    But 08 and 09 don’t exist in the system, so they return 0.

    Also see this question that also provides a solution: Specify the base parameter when doing the parseInt:

    parseInt("09", 10);  // base 10
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 500k
  • Answers 500k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer i use protected void Application_Error(object sender, EventArgs e) in my… May 16, 2026 at 1:53 pm
  • Editorial Team
    Editorial Team added an answer This just ended up to be a weird thing between… May 16, 2026 at 1:53 pm
  • Editorial Team
    Editorial Team added an answer You would access the client object model from Silverlight. Silverlight… May 16, 2026 at 1:53 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have this script that basically will show a product or products based on
I'm using nginx with this script as FastCGI wrapper, that I start with: spawn-fcgi
Howdy, I'm writing a batch script that will run on a Windows XP machine.
I have a simple PHP script that will either serve up a streaming ASF
I am trying to implement a php script which will run on every call
I have a little Bash script which suspends the computer after a given number
I want to get screenshots of a webpage in Python. For this I am
I'm trying to write (what I thought would be) a simple bash script that
I've got a script that forces a download to a user programatically. In IE
I am creating file upload script and I'm looking for the best techniques and

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.