...

View Full Version : Day (in date) with 2 digits



lebronletchev
10-02-2008, 05:08 PM
Hi,

How I write the following using a javascript?

2008/10/02

Thank you

Lebron

lebronletchev
10-02-2008, 05:16 PM
I did the following, but not works!





<SCRIPT LANGUAGE="JavaScript">



<!-- Begin
var months=new Array(13);
months[1]="01";
months[2]="02";
months[3]="03";
months[4]="04";
months[5]="05";
months[6]="06";
months[7]="07";
months[8]="08";
months[9]="09";
months[10]="10";
months[11]="11";
months[12]="12";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
if (year<100) year="19" + time.getYear();
else year=time.getYear();
document.write("<center>" + year + lmonth + " ");
if (Date < 10)
document.write(0 + date + ", " + "</center>");
else
document.write(date + ", " + "</center>");
// End -->
</SCRIPT>
<!-- END OF SCRIPT -->






Thanks

Lebron

vwphillips
10-02-2008, 06:00 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title></title>
</head>

<body>
<SCRIPT LANGUAGE="JavaScript">



<!-- Begin
function FormatNu(nu){
return nu>9?nu:'0'+nu;
}

var time=new Date();
var lmonth=time.getMonth() + 1;
var date=time.getDate();
var year=time.getFullYear();
else year=time.getYear();
document.write("<center>" + year +" "+ FormatNu(lmonth) + " ");
document.write(FormatNu(date) + ", " + "</center>");
// End -->
</SCRIPT>
</body>

</html>

lebronletchev
10-02-2008, 06:11 PM
Thank you.

It gives an error message at:


else year=time.getYear();

Why?

Lebron

vwphillips
10-03-2008, 08:26 AM
oops


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title></title>
</head>

<body>
<SCRIPT LANGUAGE="JavaScript">



<!-- Begin
function FormatNu(nu){
return nu>9?nu:'0'+nu;
}

var time=new Date();
var lmonth=time.getMonth() + 1;
var date=time.getDate();
var year=time.getFullYear();
document.write("<center>" + year +" "+ FormatNu(lmonth) + " ");
document.write(FormatNu(date) + ", " + "</center>");
// End -->
</SCRIPT>
</body>

</html>

lebronletchev
10-03-2008, 11:03 AM
Dear VWPhillips ,

Thank you. The script it is working fine now, thanks to your help!

Lebron



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum