Web Page How-To - Date Comparision

This example will display an image if a number of days hasn't passed.If more than x number of days have passed then no image will appear.

Defines:
Limit is the number of days to show the image.
Today is today's date in number of milliseconds, since Jan 01, 1970.
Dte is the date passed into the function. This is the date you are comparing to.
NDte is Dte converted into number of milliseconds since Jan 01, 1970.
Dff is the number of days between today and Dte.
864e5 is the number of milliseconds in one day.
(60sec * 60min * 24hrs = 864000sec_per_day = 643e5millisec_per_day)

How it Works:
Today's date is first saved to the variable 'today'. Dte is then converted into the number of milliseconds that has passed since Jan 01, 1970 and saved to the variable 'NDte'. The difference between 'today' and 'NDte' is then divided by the number of milliseconds in one day, this result is saved to the variable 'Dff' as the number of days between today's date and the comparision date. If 'Dff' is less than or equal to 'Limit' then the document will display the image, else it will end doing nothing.

Insert this in the webpage head
<SCRIPT>
function CheckDat(Dte){

limit = 30

today = new Date()
NDte = new Date(Date.parse(Dte))
Dte = (today = NDte)/864e5

if (Dff <= Limit) {
document.writeln ("<img SRC=\"path_of_image" NOSAVE HEIGHT=10 WIDTH=10 >")
}
}
</SCRIPT>

Insert this where you want the image to appear in the webpage body:
<SCRIPT>
CheckDat("11/01/2004")
</SCRIPT>

This file last modified 05/21/21
The site admins and owner are able to remove, change, ban, or add any content, users, or information at their will. We take no responsibility for any damage that you may cause yourself or others due to following information on this site. We cannot guarantee 100% accuracy with any data posted. If you find any language or text on this site offends you then please let the site admin know so that the proper actions can be taken. Please accept our apology now for any offensive material. We do our best to keep everything politically correct, but also reserve the right to keep any information up that we feel the user is over reacting on. We thank you for taking the time to stop by our site.