Count Down in Days Script (tutorial)

I use 3 mobiles in my store so customers can call me from their cell phone with out charge.
Every 90 days i must re charge the numbers with 10 Euros…
So to remember it i wrote(with little help from a friend, thank you John) the following script and i use it in a tile with the following format

{CALL:mobile.countdown(yr,m,d)}

So if you want countdown to March 10 2016 the format should be:

{CALL:mobile.countdown(2016,3,10)}

It’s a litlle tricky to enter countdown date, if i discover easier way i will update :smile:

Name: CountDown
Handler: mobile

var before="Mobile recharge!"
var current="TODAY IS MOBILE DAY!!!"
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
function countdown(yr,m,d){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy
var futurestring=montharray[m-1]+" "+d+", "+yr
var difference=(Math.round((Date.parse(futurestring)-Date.parse(todaystring))/(24*60*60*1000))*1)
if (difference==0)
return (current)
else if (difference>0)
return ("Only "+difference+" days for recharge.")
}



4 Likes