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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:05:59+00:00 2026-05-21T22:05:59+00:00

var d1 = Date.parse(date); // eg, 7th jan var d2 = Date.today(); // eg,

  • 0
var d1 = Date.parse(date); // eg, 7th jan
var d2 = Date.today(); // eg, 2nd jan

I want to do:

(d2 - d1).days

which with the above data, should return 5.

Is this possible with datejs?

  • 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-21T22:06:01+00:00Added an answer on May 21, 2026 at 10:06 pm

    The optional TimeSpan module includes functionality to easily get various value differences between two date objects.

    http://code.google.com/p/datejs/source/browse/trunk/src/time.js

    Just include after your main date.js include, or combine.

    In the “time.js” file, there’s also a TimePeriod class. You might not require, so just crop what you need if weight is an issue.

    The following sample demonstrates the full scenario.

    Example

    var d1 = Date.parse("jan 7"); // eg, 7th jan
    var d2 = Date.parse("jan 2"); // eg, 2nd jan
    
    console.log(new TimeSpan(d1 - d2).days); // 5
    

    Hope this helps.

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

Sidebar

Related Questions

Why cannot IE parse this string as a Date object. var d = Date.parse(Fri
$.validator.addMethod(enddate, function (value, element) { var startdatevalue = $('#StartDate').val(); return Date.parse(startdatevalue) < Date.parse(value); });
Date.parseWeird=Date.prototype.parseWeird=function(d) { return new Date(Date.parse(d)); }; var d = /Date(-65424600000)/ How can i parse
var i : integer; i := 1234567; Given the above, I want the string
I have this string containing a date I need to parse to get a
var AppPatientsList = JSON.parse(JSON RESPONSE); var AppPatientsListSort = AppPatientsList.sort(function(a,b){ return a.firstName.toLowerCase() <b.firstName.toLowerCase() ? -1
This query works great: var pageObject = (from op in db.ObjectPermissions join pg in
I have tried like this <script type=text/javascript> var date2=02/09/2009; var date1=03/12/2009; var diff =
I render this JSON object: [{created_at:2010-09-21T20:41:28Z,subject:hello world}] Then I use this date parser to
I have some code that tries to parse a date string. When I do

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.