Skip to content

Instantly share code, notes, and snippets.

@lukegalea
Last active December 22, 2015 20:19
Show Gist options
  • Save lukegalea/6525408 to your computer and use it in GitHub Desktop.
Save lukegalea/6525408 to your computer and use it in GitHub Desktop.
A Pen by Luke Galea.
<div class="before">
<div class="daysBefore">
It's
<span class="days"></span>
days before
</div>
<div class="hoursBefore">
It's
<span class="hours"></span>
hours before
</div>
</div>
<div class="open">
It's open
</div>
$(function() {
var daysAway, hoursAway, launchDate, now, isLaunched;
launchDate = moment("09-17-2013 10:00 +5", "MM-DD-YYYY HH:mm Z");
now = moment();
daysAway = launchDate.diff(now, 'days');
hoursAway = launchDate.diff(now, 'hours');
isLaunched = now.isAfter(launchDate);
$('.days').text(daysAway);
$('.hours').text(hoursAway);
$('.before').toggle(!isLaunched);
$('.open').toggle(isLaunched);
$('.daysBefore').toggle(hoursAway > 24);
$('.hoursBefore').toggle(hoursAway <= 24);
});
.hidden {
display: none;
}
@lukegalea
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment