Date Calculations

Thanks. I am just getting my feet wet. Apparently Javascript was developed when web browsers were hot and hey, they still are. So I see examples wrapped in html tags which I don’t actually need - in TextExpander. For example if I copy a line that starts with “document.write” TextExpander goes “WTF?” No documents here. So I am still at It.

Doing a tutorial just now using Safari/Firefox and a text editor ((TextWrangler).

FINISHED!

OK, for anyone who is interested, here is what I learned (mostly from others work but also some trial and error and new understandings). The following now triggers a macro when triggered in TextExpander:

now = new Date()
var d1 = new Date(); //"now"
var d2 = new Date (new Date(now.getFullYear(), now.getMonth() +1 , 1) - 1)
var diff = Math.abs(d2-d1);  // difference in milliseconds
var one_day=1000*60*60*24; // milliseconds
var res1 =  Math.round(diff/one_day);
res1 + " days"