home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2004 March
/
PCWMAR04.iso
/
javascript
/
date.js
< prev
next >
Wrap
Text File
|
2003-07-28
|
1KB
|
37 lines
if (typeof(addtime) == "undefined")
var addtime = true;
days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
function renderDate(){
var mydate = new Date();
var year;
if (mydate.getFullYear)
year = mydate.getFullYear();
else {
year = mydate.getYear();
if (year < 100)
year = parseInt(2000 + year);
else
year = parseInt(1900 + year);
}
var day = mydate.getDay();
var month = mydate.getMonth();
var daym = mydate.getDate();
if (daym < 10)
daym = "0" + daym;
var hours = mydate.getHours();
var minutes = mydate.getMinutes();
var dn = "AM";
if (hours >= 12) {
dn = "PM";
hours = hours - 12;
}
if (hours == 0)
hours = 12;
if (minutes <= 9)
minutes = "0" + minutes;
document.writeln(" ",days[day]," ",daym," ",months[month]," ",year,(addtime?" | "+hours+":"+minutes+" "+dn:""));
}
renderDate();