Current Date and Time

P

Peter

I have a script which gives me the current date and time. Works fine, but
how can I change the format to day, date, month, year?



For example

Currently it gives Saturday May 8, 2004



I would like Saturday 8 May 2004



<SCRIPT language=JavaScript><!--
var DayOfWeek = new
Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'
);
var MonthName = new
Array('January','February','March','April','May','June','July','August','Sep
tember',
'October','November','December');
var theDate = new Date();

document.write('<NOBR>' +
DayOfWeek[theDate.getDay()] + ' ' +
MonthName[theDate.getMonth()] + ' ' +
theDate.getDate() + ', ' +
(theDate.getYear() < 200 ? theDate.getYear() + 1900 :
theDate.getYear()) +
'</font></NOBR>');
//--></SCRIPT>
</h3>


Thanks



Peter
 
N

Net55

Just remove the , between the " , " if you don't want them

<script language="JavaScript">
days = new Array(7)
days[1] = "Sunday";
days[2] = "Monday";
days[3] = "Tuesday";
days[4] = "Wednesday";
days[5] = "Thursday";
days[6] = "Friday";
days[7] = "Saturday";
months = new Array(12)
months[1] = "January";
months[2] = "February";
months[3] = "March";
months[4] = "April";
months[5] = "May";
months[6] = "June";
months[7] = "July";
months[8] = "August";
months[9] = "September";
months[10] = "October";
months[11] = "November";
months[12] = "December";
today = new Date(); day = days[today.getDay() + 1]
month = months[today.getMonth() + 1]
date = today.getDate()
year=today.getYear();
if (year < 2000)
year = year + 1900;
document.write ("<font size=-2 face='Arial, Helvetica,
sans-serif' color=003399> "+ day +
", " + date + " " + month + ", " + year + "</font>")
// -- end hiding
</script>

Net55
(e-mail address removed)
http://www.frontpagewiz.com
-----Original Message-----
I have a script which gives me the current date and time. Works fine, but
how can I change the format to day, date, month, year?



For example

Currently it gives Saturday May 8, 2004



I would like Saturday 8 May 2004



<SCRIPT language=JavaScript><!--
var DayOfWeek = new
Array ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday
','Saturday'
);
var MonthName = new
Array ('January','February','March','April','May','June','July','
August','Sep
tember',
'October','November','December')
;
var theDate = new Date();

document.write('<NOBR>' +
DayOfWeek[theDate.getDay()] + ' ' +
MonthName[theDate.getMonth()] + ' ' +
theDate.getDate() + ', ' +
(theDate.getYear() < 200 ? theDate.getYear () + 1900 :
theDate.getYear()) +
'</font></NOBR>');
//--></SCRIPT>
</h3>


Thanks



Peter


.
 
N

Net55

this forum puts a break on this line:

document.write ("<font size=-2 face='Arial, Helvetica,
sans-serif' color=003399> "+ day +

Put it on thesame line and the script will work :)

-----Original Message-----
Just remove the , between the " , " if you don't want them

<script language="JavaScript">
days = new Array(7)
days[1] = "Sunday";
days[2] = "Monday";
days[3] = "Tuesday";
days[4] = "Wednesday";
days[5] = "Thursday";
days[6] = "Friday";
days[7] = "Saturday";
months = new Array(12)
months[1] = "January";
months[2] = "February";
months[3] = "March";
months[4] = "April";
months[5] = "May";
months[6] = "June";
months[7] = "July";
months[8] = "August";
months[9] = "September";
months[10] = "October";
months[11] = "November";
months[12] = "December";
today = new Date(); day = days[today.getDay() + 1]
month = months[today.getMonth() + 1]
date = today.getDate()
year=today.getYear();
if (year < 2000)
year = year + 1900;
document.write ("<font size=-2 face='Arial, Helvetica,
sans-serif' color=003399> "+ day +
", " + date + " " + month + ", " + year + "</font>")
// -- end hiding
</script>

Net55
(e-mail address removed)
http://www.frontpagewiz.com
-----Original Message-----
I have a script which gives me the current date and time. Works fine, but
how can I change the format to day, date, month, year?



For example

Currently it gives Saturday May 8, 2004



I would like Saturday 8 May 2004



<SCRIPT language=JavaScript><!--
var DayOfWeek = new
Array
('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday
','Saturday'
);
var MonthName = new
Array
('January','February','March','April','May','June','July','
August','Sep
)
;
var theDate = new Date();

document.write('<NOBR>' +
DayOfWeek[theDate.getDay()] + ' ' +
MonthName[theDate.getMonth()] + ' ' +
theDate.getDate() + ', ' +
(theDate.getYear() < 200 ? theDate.getYear () + 1900 :
theDate.getYear()) +
'</font></NOBR>');
//--></SCRIPT>
</h3>


Thanks



Peter


.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top