functionality:
User to play a game and when user wins, they will be navigated to a redemption page. Users are to redeem the goodies from the goodie page within 72hrs. Therefore, the redemption will expire 72 hours from the system time that the user is at the "congratulation" redemption page.
what has been done:
First, I have tried to get the current systemTime the moment user is navigated to the congratulation page.
Secondly, I have tried to get the expiry date by adding 3 additional days to set it as 72 hours later.
Lastly, I try to append the calculated expiry date to the <div>
for expiry date.
Issue:
Somehow, the expiry date is not shown correctly. For example, if today's date is the 8/3, however, the result is showing 14/2.
Therefore, the date is not showing 72 hours later but a month and a few days ago.
What have I done wrong??
function win() {
//get current System Time and Date
var endDate = new Date();
//Get Expiry Date
var date = new Date(endDate);
date.setDate(date.getDate() + 3);
var expiryDate = (date.getDate() + 3) + "/" + (date.getMonth());
document.getElementById('ExpiryDate').innerHTML = expiryDate;
console.log("test");
$("#my-memory-game").fadeOut(function() {
win_video();
})
}
<div id="congratulations">
<canvas id="MyCanvas" style="width:1080px; height: 1920px;">
Your browser does not support the HTML5 canvas tag.
</canvas>
<div id="ExpiryDate"></div>
</div>