Subtracting dates & issues with document.write

im using a script i made that looks like this:
var year = time.getYear();
var months = time.getMonth();
var days = time.getDate();
posteddate = 20061121;
var prestamp = Math.ceil((year10000)+(months100)+days);
var enddate = Math.ceil(prestamp-posteddate);

Which converts the current date into this format: yyyymmdd or 20061124 for november 24 2006. and it subtracts posteddate which is november 21 2006. The result should be 3. However, in IE and FF, nothing is displayed at all. Not even a sign that the script is working… Can someone help? I’m pretty sure that it has more to do with document.write not writing rather than the math not being right, because IE doesn’t pickup errors, and FF never says anything anyways… so…