javascript - Increment a var by one every 24 hours from a specific date -



javascript - Increment a var by one every 24 hours from a specific date -

i've never used javascript before (or other programming language) sorry asking question because im sure it's simple.

what want set date in javascript, increment 1 every 24 hours. 3 days after date set, 3 displayed in html (not date itself). , after 100 days, 100 displayed.

thank you.

you have create 2 date objects, 1 representing initial date, , 1 representing right now. then, calculate difference:

// calculate days since dec 1st 2012 var initialdate = new date(2012, 11, 1); // attention: month zero-based var = date.now(); var difference = - initialdate; var millisecondsperday = 24 * 60 * 60 * 1000; var dayssince = math.floor(difference / millisecondsperday); alert(dayssince); // 80

http://jsfiddle.net/pmyfc/

javascript date increment

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -