ethayne
18 Nov 2008, 04:25 PM
Hi, I have some code that I'm using for a site that sells massage chairs. Basically, it says "Estimated Delivery:" and then Javascript outputs a date that is exactly 2 weeks from the current date. Here's what I have right now:
<small>Estimated Delivery:</small><br/>
<script>
DaysToAdd=14;
var now=new Date();
var newdate=new Date();
var newtimems=newdate.getTime()+(DaysToAdd*24*60*60*1000);
newdate.setTime(newtimems);
document.write('<font size="5" color="#72D1F6">' + newdate.format('M jS, Y') + '</font>');
</script>
At this point I'm not getting any output. When I replace newdate.format(...) with newdate.toLocaleString(), I do get the date, but not formatted.
Any idea what I'm doing wrong?
Thanks!
<small>Estimated Delivery:</small><br/>
<script>
DaysToAdd=14;
var now=new Date();
var newdate=new Date();
var newtimems=newdate.getTime()+(DaysToAdd*24*60*60*1000);
newdate.setTime(newtimems);
document.write('<font size="5" color="#72D1F6">' + newdate.format('M jS, Y') + '</font>');
</script>
At this point I'm not getting any output. When I replace newdate.format(...) with newdate.toLocaleString(), I do get the date, but not formatted.
Any idea what I'm doing wrong?
Thanks!