| Code: : |
| <script type="text/JavaScript"> // get the date and time information var date = new Date(); var month = new String; var day = new String; var year = new String; var seconds = date.getSeconds(); var minutes = date.getMinutes(); var hours = date.getHours(); var pmam=(hours >= 12)? " P.M.":" A.M."; var month = date.getMonth() var day = date.getDate() // This is the y2k fixer function--don't worry about how this works, // but if you want it in your scripts, you can cut and paste it. // function y2k(number) { return (number < 1000) ? number + 1900 : number; } // Get the year and fix the y2k bug using the fixer function. // var year = y2k(date.getYear()) // Translate the number of the month to a word--so 0 becomes January, 1 becomes February, etc... // if (month == 0) month = "Jan."; else if (month == 1) month = "Feb."; else if (month == 2) month = "March"; else if (month == 3) month = "April"; else if (month == 4) month = "May"; else if (month == 5) month = "June"; else if (month == 6) month = "July"; else if (month == 7) month = "Aug."; else if (month == 8) month = "Sep."; else if (month == 9) month = "Oct."; else if (month == 10) month = "Nov."; else if (month == 11) month = "Dec."; //this code says if the day is 1 then add 'st' after it and so on and so forth, no need to edit this. if (day == 1) day = day + "<sup>st</sup>"; else if (day == 2) day = day + "<sup>nd</sup>"; else if (day == 3) day = day + "<sup>rd</sup>"; else if (day > 3 && day < 20) day = day + "<sup>th</sup>"; else if (day == 21) day = day + "<sup>st</sup>"; else if (day == 22) day = day + "<sup>nd</sup>"; else if (day == 23) day = day + "<sup>rd</sup>"; else if (day > 23 && day < 31) day = day + "<sup>th</sup>"; else if (day == 31) day = day + "<sup>st</sup>"; //edit time to 12 hour rather than 24 hour...you can take this out if you want it to be based on 24 hour if (hours > 12) { hours = hours - 12; } //adds zero before the minute if it is below 10 if (minutes < 10) { minutes = "0" + minutes; } //adds zero before the second if it is below 10 if (seconds < 10) { seconds = "0" + seconds; } // declare the sentence as a variable(as it makes it easier to display later on) //you can change this sentence to be what ever you want var display_date = ("" + month + " " + day + ", " + year); //of course it could be a good idea to edit this to your liking, i personally wouldn't keep the seconds, but that's just me var display_time = ("" + hours + ":" + minutes + ":" + seconds + pmam); // --> </script> |
| Code: : |
| <!-- Ok, now that you have the script ready, add this line of code wherever you want the date to appear: --> <script type="text/Javascript"> document.write(display_date); document.write(". "); document.write(display_time); </script> |