Copyright 2003, Groundbreak.com. All rights reserved.
Any comments, suggestions, or mistakes: smiles@groundbreak.com

Javascript tips and tricks

1. Date trick

This javascript code prints out the date - but the trick is that you can set the date to ANY time in the future. This is great when you want to say, "This special is only good for three more days, please join by ". And it keeps on moving forward - always enticing your visitors to buy in the next three days...

Here's the code you'll cut and paste into your HTML pages. Note the line in the middle where you can edit the 3 which represents the number of days after the current date you want the new date to be.

<script type="text/javascript">
var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var today = new Date()
var todayInMS = today.getTime()
var inthreedays = todayInMS + (60 * 60 * 24 * 3 * 1000) // edit the 3 to change the number of days
var newdate = new Date(inthreedays)
document.write(weekday[newdate.getDay()] + ", ")
document.write(monthname[newdate.getMonth()] + " ")
document.write(newdate.getDate() + " ")
document.write(newdate.getFullYear())
</script>



© 1998 - present Groundbreak.com, All Rights Reserved