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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:06:41+00:00 2026-06-12T13:06:41+00:00

var dateObj = new Date(); var val = dateObj.getTime(); //86400 * 1000 * 3

  • 0
var dateObj = new Date();
var val = dateObj.getTime();
//86400 * 1000 * 3  Each day is 86400 seconds
var  days = 259200000;

val = val + days;
dateObj.setMilliseconds(val);
val = dateObj.getMonth() + 1 + "/" + dateObj.getDate() + "/" + dateObj.getFullYear();
alert(val);

I am trying to take the current date, add three days of milliseconds to it, and have the date stamp show 3 days later from the current. For example – if today is 10/09/2012 then I would like it to say 10/12/2012.

this method is not working, I am getting the months and days way off. Any suggestions?

  • 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-12T13:06:42+00:00Added an answer on June 12, 2026 at 1:06 pm

    To add time, get the current date then add, as milliseconds, the specific amount of time, then create a new date with the value:

    // get the current date & time (as milliseconds since Epoch)
    const currentTimeAsMs = Date.now();
    
    // Add 3 days to the current date & time
    //   I'd suggest using the calculated static value instead of doing inline math
    //   I did it this way to simply show where the number came from
    const adjustedTimeAsMs = currentTimeAsMs + (1000 * 60 * 60 * 24 * 3);
    
    // create a new Date object, using the adjusted time
    const adjustedDateObj = new Date(adjustedTimeAsMs);
    

    To explain this further; the reason dataObj.setMilliseconds() doesn’t work is because it sets the dateobj’s milliseconds PROPERTY to the specified value(a value between 0 and 999). It does not set, as milliseconds, the date of the object.

    // assume this returns a date where milliseconds is 0
    dateObj = new Date();
    
    dateObj.setMilliseconds(5);
    console.log(dateObj.getMilliseconds()); // 5
    
    // due to the set value being over 999, the engine assumes 0
    dateObj.setMilliseconds(5000);
    console.log(dateObj.getMilliseconds()); // 0
    

    References:
    Date.now()
    new Date()
    Date.setMilliseconds()

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

Sidebar

Related Questions

I have this date format , var dateobj = 'Apr 28, 2011 6:01:23 AM';
var conversations = new Array(); jQuery('.CChatWindow').each(function(){ if (jQuery(this).is(:visible) && jQuery(this).attr(data-conversationid) != 0) { alert(jQuery(this).attr(data-conversationid));
public string Process<T>(string name, string address) { var dataObj= new Data<T>(); List<T> currentList= dataObj.GetAll(name);
var ref1 = new Firebase(http://gamma.firebase.com/myuser/123,456); ref1.set(123,456); var on1 = ref1.on(value, function(snapshot) { console.log(snapshot.val()); });
I have a twitter feed and I create a new date obj so I
var x = '#google'; // or '@google' or '%google' var pattern = new RegExp('(^|\\s)'
var queueitem = context.CrawlerQueues. Select(cq => new{cq.Guid,cq.Result}). SingleOrDefault(cq => cq.Guid == guid); Is above
var chart; var d = new Array(); function click() { d = document.getElementById('graph:hi').value; alert(d);
var myOptions_bench = { 1 : '1', 2 : '2', 3 : '3'} $.each(myOptions_bench,
var results = ['one', 'two', 'one hundred', 'three']; var removal = []; $.each(results, function(i)

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.