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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:45:09+00:00 2026-05-24T12:45:09+00:00

I am writing a timer web app,which records start time and stop time.It uses

  • 0

I am writing a timer web app,which records start time and stop time.It uses javascript,jquery1.4.2 for the front end and python for backend code.When a start button is clicked ,start time is saved in a javascript variable.when the button is clicked again, stop time is saved in another variable.These values are passed as hidden parameters to the python code which gets the start,stop values from django‘s request parameter.

I expect the start/stop parameters values to be in the following format

"07:16:03 PM"

so that it can be parsed using '%I:%M:%S %p'format string.
I am getting this correctly in mozilla firefox.But when I use chrome,I only get

"19:16:03"

This causes value error when I try to parse it with the above format string.

import time
...
def process_input(request,...):    
    start_time=request.POST[u'timerstarted']
    ...
    fmtstr='%I:%M:%S %p'
    start_time_list = list(time.strptime(start_time,fmtstr)[3:6])

I tried putting alert('start time set as'+start_time) in javascript to find what values are set in the page’s hiddenfields

With firefox ,I got

start time set as08:03:09 PM
stop time set as08:03:43 PM

but with chrome

start time set as20:04:21
stop time set as20:04:32

My knowledge of javascript,jquery is minimal.Why is the script behaving differently in these two browsers? Below is the javascript snippet

$(document).ready(function(){
    var changeBtnStatus=function(){
    var timebtnvalue=$('#timebtn').attr("value");

    if (timebtnvalue =="start"){
        ...      
        var start_date=new Date();
        var str_time=start_date.toLocaleTimeString();       
        var timerstartedfield =$('#timerstarted');              
        timerstartedfield.attr("value",str_time);        
        alert('start time set as'+str_time);

    }
    else if (timebtnvalue=="stop"){
        ...            
        var stop_date=new Date();
        var stp_time=stop_date.toLocaleTimeString();        
        var timerstoppedfield =$('#timerstopped');
        timerstoppedfield.attr("value",stp_time);             
        alert('stop time set as'+stp_time);       
    }
};
var timerBtnClicked=function(){   
    ...
    changeBtnStatus();
};

$('#timebtn').click(timerBtnClicked);

...
}
);
  • 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-24T12:45:10+00:00Added an answer on May 24, 2026 at 12:45 pm

    You don’t want the string of the time in locale, using the toString method you can provide your own format, or use toUTCString().

    toLocaleTimeString is especially meant to display the time as the user is used to, you want it in a set format.

    So instead of start_date.toLocaleTimeString(), you want to use start_date.toUTCString().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm about to start writing a web app (Asp.Net/IIS7) which will be accessible over
I am writing a web app in PHP, and it has come time to
I'm currently writing a client-side javascript app which performs image manipulation. Some of the
I am writing a business app in Flex that uses web services to communicate
I'm writing a web app using grails and spring-security 3.0.3 which requires me to
Hey everyone.. This is my first time writing an ASP.NET MVC web app, and
I'm just writing a javascript UI dialog for a web app. The problem is
I'm writing php web-app using unholy alliance of php+oracle+iis :) every time script being
I've been writing PHP web applications for some time, and have come across very
I'm writing an app that will need to make use of Timer s, but

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.