Skip to content

Instantly share code, notes, and snippets.

@arun12209
Last active June 29, 2019 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arun12209/041d80a46db96126452fae5dd4cc3c39 to your computer and use it in GitHub Desktop.
Save arun12209/041d80a46db96126452fae5dd4cc3c39 to your computer and use it in GitHub Desktop.
OpptyCloseTimerCmpHelper
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