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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:19:20+00:00 2026-06-15T01:19:20+00:00

Im having some troubles with conversion. It says invalid date when alert(first_date) and alert(end_date)

  • 0

Im having some troubles with conversion. It says invalid date when alert(first_date) and alert(end_date),etc :s Im using datetimepicker to get the dates.

$( "#start_date" ).datetimepicker({
            dateFormat : 'yy-mm-dd',
            timeFormat: 'hh:mm:ss',
            defaultDateTime: "+1w",
            showSecond: true,
            changeMonth: true,
            changeYear: true,
            onClose: function( selectedDateTime ) {
                $( "#end_date" ).datetimepicker( "option", selectedDateTime );
            }
        });
        $( "#end_date" ).datetimepicker({
            dateFormat : 'yy-mm-dd',
            timeFormat: 'hh:mm:ss',
            defaultDateTime: "+1w",
            showSecond: true,
            changeMonth: true,
            changeYear: true,
            onClose: function( selectedDateTime ) {
                $( "#start_date" ).datetimepicker( "option", selectedDateTime );
            }
        });

Now, I need to do something like this:

var first_date = new Date($('#start_date').val());
var last_date = new Date($('#end_date').val());
var nDifference = (last_date - first_date);
var one_day = 1000*60*60*24;
var days = Math.round(nDifference/one_day);

<input type="text" id="start_date" name="start_date" value=""/>
<input type="text" id="end_date" name="end_date" value=""/>
  • 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-15T01:19:21+00:00Added an answer on June 15, 2026 at 1:19 am

    Javascript date reliably accepts ISO date formats…

    d = '2012-01-01 06:16:16'
    
    console.log(new Date(d)) // invalid
    console.log(new Date(d.replace(' ','T'))) // valid!
    // Z at the end accounts for local timezone offset
    console.log(new Date(d.replace(' ','T')+'Z'))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some troubles using Session Variables as they are being used as Reference
I am using VS2012 and having some troubles publishing an mvc4 website. None of
I'm having some troubles pausing and resuming a method. (Using Java in Eclipse). Basically
I'm having some troubles right now I am using git flow and created a
I've been having some troubles to get an IF/ELSE statement working. I have the
I am having some troubles using the +UIImage setImageWithURL: method. What I would like
Im having some troubles trying to get the info stored in my database and
I'm having some troubles adding an UIView to cocos2d v2.0 since the openGlView is
guys am having some troubles with running out of memory when displaying an animation
I'm developing a website in WordPress and I'm having some troubles with the the

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.