Last active
June 29, 2019 05:03
-
-
Save arun12209/041d80a46db96126452fae5dd4cc3c39 to your computer and use it in GitHub Desktop.
OpptyCloseTimerCmpHelper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var interval = window.setInterval( | |
$A.getCallback(function() { | |
//Fomart the Opportunity Close Date | |
var opptyCloseDate = new Date( closeDate+" 00:00:00 "); | |
//Todays date | |
var now_date = new Date(); | |
// time difference between opportunity close date and today's date | |
var timeDiff = opptyCloseDate.getTime()- now_date.getTime(); //Return the number of milliseconds since 1970/01/01 | |
component.set("v.isValid",true); | |
//seprate the timeDiff into total seconds, minnutes, hours and days. | |
var seconds=Math.floor(timeDiff/1000); // seconds | |
var minutes=Math.floor(seconds/60); //minute | |
var hours=Math.floor(minutes/60); //hours | |
var days=Math.floor(hours/24); //days | |
//get the remaining hours, minutes, seconds. | |
hours %=24; | |
minutes %=60; | |
seconds %=60; | |
//put the calculated value in lightning component Attributes. | |
component.set("v.day",days); | |
component.set("v.hour",hours); | |
component.set("v.minute",minutes); | |
component.set("v.second",seconds); | |
}), 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment