Advertisement
containes

s

Apr 22nd, 2014
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function calcDate(target,message) {
  2.   var today = new Date();
  3.   var past = target;
  4.   var diff = Math.floor(today.getTime() - past.getTime());
  5.   var day = 1000* 60 * 60 * 24;
  6.  
  7.   var days = Math.floor(diff/day);
  8.   var months = Math.floor(days/30);
  9.   days = days%30;
  10.   var years = Math.floor(months/12);
  11.   months = months%12;
  12.  
  13.   console.log("MeBeiM's timer-since.js >> Loaded");
  14.  
  15.   if ((months!=0) && (days!=0)) var andmonths=true;
  16.   if ((years!=0) && (months!=0) && (days!=0)) var commayears=true;
  17.   if ((years!=0) && (months!=0) && (days==0)) var andyears=true;
  18.   if ((years!=0) && (months==0) && (days!=0)) var andyears=true;
  19.  
  20.   (days>0) ? ((days>1) ? days = "<b>"+days.toString()+"</b> days" : days = "<b>"+days.toString()+"</b> day") : days = "";
  21.   (months>0) ? ((months>1) ? months = "<b>"+months.toString()+"</b> months" : months = "<b>"+months.toString()+"</b> month") : months = "";
  22.   (years>0) ? ((years>1) ? years = "<b>"+years.toString()+"</b> years" : years = "<b>"+years.toString()+"</b> year") : years = "";
  23.  
  24.   if (andmonths) months+=" and ";
  25.   if (andyears) years+=" and ";
  26.   if (commayears) years+= ", ";
  27.  
  28.   message = message.replace('%%TIME%%',years+months+days);
  29.  
  30.   document.write(message);
  31.   if (location.hostname != "passivelove.tk")
  32.     document.write('<a href="" target="_blank" style="position: absolute;left: 3px;bottom: 0px;font-size: 14px;color: #D3D3D3;text-decoration:none;" title="Tab#1 by passivelove"></a>');
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement