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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:27:14+00:00 2026-06-12T00:27:14+00:00

I am making a website where if a user logs in, the user is

  • 0

I am making a website where if a user logs in, the user is given a certain logout time, where the logout time is defined and the timeleft is obtained from the logout time – server time.

I’ve already got the logout time and server time via PHP, but I want to display the time left dynamically thus requiring Javascript. I’ve tried using the following code:

function timerStart(arg1, arg2){
    var counter = setInterval(function() {getTimeLeft(arg1,arg2); }, 1000);
}

function getTimeLeft(arg_endtime, arg_currenttime){
    var endtime = new Date(arg_endtime);
    var curtime = new Date(arg_currenttime);

    var timeleft = new Date(endtime - curtime); //endtime - curtime;

    tlHours = timeleft.getHours();
    tlMinutes = timeleft.getMinutes();
    tlSeconds = timeleft.getSeconds();

    document.getElementById("timeleft").value = tlHours + ":" + tlMinutes + ":" + tlSeconds;

}

Where arg1’s value is ‘2011:10:11 17.30.00’ and arg2’s value is ‘2011:10:11 15:55:31’ as a string (yes, they are in different format). But when I tried the above codes I get NaN:NaN:NaN. I am very new to Javascript (3 days) and trying to catch up a deadline so a thorough explanation is very appreciated.

  • 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-12T00:27:15+00:00Added an answer on June 12, 2026 at 12:27 am

    The format to the Date() function has to be very specific.

    I’ve mocked it up here: http://jsfiddle.net/PtGxk/

    As you can see of your dates are ‘/’-separated and your times ‘:’-seprated, everything is ok.

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

Sidebar

Related Questions

I'm making a website that (essentially) lets the user submit a word, matches it
I am making a website where a user can create an account and then
I'm making a website with specific posts that have tags created by the user.
For mobile web development: I am making a website which asks the user (on
Im making a website where it has a user registration. What I was going
I am making a website that displays a user's chosen youtube videos. A user
I'm making a website with a simple form on the homepage. When the user
I'm making website that have notification 'button'. When user click this button, notification div
I am making one website about books and the user reaches the book which
I am making a social website that each user can view his own or

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.