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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:56:38+00:00 2026-05-25T05:56:38+00:00

I use this script currently to determine the difference between two dates: // Slide_Tracker[?].date_int

  • 0

I use this script currently to determine the difference between two dates:

// Slide_Tracker[?].date_int are results from the built in function getTime()
var current_date = new Date(Slide_Tracker[i].date_int);
var past_date:Date = new Date(Slide_Tracker[i - 1].date_int);
var date_diff:Number = Math.round((current_date - past_date) / 86400000);

The problem with this is I want to monitor the actual physical day change so if someone accessed the application at 11:59 PM and then came back 5 minutes later this would register as a 1 day difference (a new day), this current script requires atleast 12 hours to have passed between two dates for it to register as a new day.

I have thought about using the date number etc, but because months and years are so different it is quite a complex route, there must be something simpler.

  • 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-25T05:56:39+00:00Added an answer on May 25, 2026 at 5:56 am

    As an FYI, the difference between a date and midnight of the following AM is:

    // dt is the start date
    var diff:Number = 
          new Date(dt.getYear(), dt.getMonth(), dt.getDate() + 1) - dt.getTime()
    

    But it is easiest to simply round to the next day and then start from there:

    var dt:Date = new Date(Slide_Tracker[i - 1].date_int);
    var past_date = // start at the next day to only deal w/ 24 hour increments
        new Date(dt.getYear(), dt.getMonth(), dt.getDate() + 1);
    dt = new Date(Slide_Tracker[i].date_int);
    var current_date = 
        new Date(dt.getYear(), dt.getMonth(), dt.getDate() + 1);
    var date_diff:Number = Math.round((current_date.getTime() - 
                                       past_date.getTime()) / 86400000);
    

    Your other option is to round the inputs:

    // rounds a timestamp *down* to the current day
    function getBaseDay(val:Number):Number
    {
        return Math.floor( val / 86400000 ) * 86400000
    }
    
    var current_date = new Date(getBaseDay(Slide_Tracker[i].date_int));
    var past_date:Date = new Date(getBaseDay(Slide_Tracker[i - 1].date_int));
    var date_diff:Number = Math.round((current_date.getTime() - 
                                       past_date.getTime()) / 86400000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use this script to equalize heights of elements: (function ($) { $.fn.autoheight =
I used to use this script for jquery email obfuscation: $(.replaceAt).replaceWith(@); $(.obfuscate).each(function () {
This is from a sql script. What tool can generate this? Thanks --USE [MY_TABLE]
This question is simple. What function would I use in a PHP script to
I copied this script from internet but idon't know how to use it. i
If I have code like this: <script> function determine() { // ???? } </script>
During development, I use this to load the latest jQuery: <script src=http://www.google.com/jsapi></script> <script type=text/javascript>
I have this .bat script which I use to maven package my application. Problem
I'm puzzled with this test script: #!perl use strict; use warnings; use encoding 'utf8';
I've got this simple Perl script: #! /usr/bin/perl -w use strict; use Data::Dumper; my

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.