Skip to main content
August 8, 2016
Answered

why im i getting errors

  • August 8, 2016
  • 2 replies
  • 1008 views

why Am I getting errors with this code?

I don't understand why!

var rightNow = new Date();

var msRightNow = rightNow.getTime();

var fiveDays = 5 * 24 * 60 * 60 * 1000;

var theNewDate = new Date(finalTime);

console.println("5 days from now is: " + theNewDate.toString());

This topic has been closed for replies.
Correct answer try67

Sorry, I do see an error now. You didn't define the finalTime variable anywhere. I think you meant to do something like this:

var rightNow = new Date();

var msRightNow = rightNow.getTime();

var fiveDays = 5 * 24 * 60 * 60 * 1000;

var finalTime = msRightNow + fiveDays;

var theNewDate = new Date(finalTime);

console.println("5 days from now is: " + theNewDate.toString());

2 replies

lrosenth
Adobe Employee
Adobe Employee
August 8, 2016

Where is this code? How it is being called? What errors?

And what does this have to do with the SDK?

try67
Community Expert
Community Expert
August 8, 2016

First of all, I moved your question to the JavaScript forum.

I don't see any errors in this code, but it is not set up to work correctly.

You need to add the fiveDays value to the msRightNow value if you want to get the date for five days from now.

So the fourth line should be:

var theNewDate = new Date(msRightNow + finalTime);

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 8, 2016

Sorry, I do see an error now. You didn't define the finalTime variable anywhere. I think you meant to do something like this:

var rightNow = new Date();

var msRightNow = rightNow.getTime();

var fiveDays = 5 * 24 * 60 * 60 * 1000;

var finalTime = msRightNow + fiveDays;

var theNewDate = new Date(finalTime);

console.println("5 days from now is: " + theNewDate.toString());

August 8, 2016

not sure if Im setup correctly, but everything I seem to enter into the console I get errors!