Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-02-2008, 05:08 PM   PM User | #1
lebronletchev
Regular Coder

 
Join Date: Oct 2006
Location: Spain
Posts: 147
Thanks: 2
Thanked 0 Times in 0 Posts
lebronletchev is an unknown quantity at this point
Cool Day (in date) with 2 digits

Hi,

How I write the following using a javascript?

2008/10/02

Thank you

Lebron
lebronletchev is offline   Reply With Quote
Old 10-02-2008, 05:16 PM   PM User | #2
lebronletchev
Regular Coder

 
Join Date: Oct 2006
Location: Spain
Posts: 147
Thanks: 2
Thanked 0 Times in 0 Posts
lebronletchev is an unknown quantity at this point
I did the following, but not works!

Quote:


<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
lebronletchev is offline   Reply With Quote
Old 10-02-2008, 06:00 PM   PM User | #3
vwphillips
Senior Coder

 
Join Date: Mar 2005
Location: Portsmouth UK
Posts: 4,358
Thanks: 3
Thanked 458 Times in 445 Posts
vwphillips is a jewel in the roughvwphillips is a jewel in the roughvwphillips is a jewel in the rough
Code:
<!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>
__________________
Vic

God Loves You and will never love you less.

http://www.vicsjavascripts.org.uk/

If my post has been useful please donate to http://www.operationsmile.org.uk/
vwphillips is offline   Reply With Quote
Old 10-02-2008, 06:11 PM   PM User | #4
lebronletchev
Regular Coder

 
Join Date: Oct 2006
Location: Spain
Posts: 147
Thanks: 2
Thanked 0 Times in 0 Posts
lebronletchev is an unknown quantity at this point
Thank you.

It gives an error message at:

Quote:
else year=time.getYear();
Why?

Lebron
lebronletchev is offline   Reply With Quote
Old 10-03-2008, 08:26 AM   PM User | #5
vwphillips
Senior Coder

 
Join Date: Mar 2005
Location: Portsmouth UK
Posts: 4,358
Thanks: 3
Thanked 458 Times in 445 Posts
vwphillips is a jewel in the roughvwphillips is a jewel in the roughvwphillips is a jewel in the rough
oops

Code:
<!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>
__________________
Vic

God Loves You and will never love you less.

http://www.vicsjavascripts.org.uk/

If my post has been useful please donate to http://www.operationsmile.org.uk/
vwphillips is offline   Reply With Quote
Old 10-03-2008, 11:03 AM   PM User | #6
lebronletchev
Regular Coder

 
Join Date: Oct 2006
Location: Spain
Posts: 147
Thanks: 2
Thanked 0 Times in 0 Posts
lebronletchev is an unknown quantity at this point
Dear VWPhillips ,

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

Lebron
lebronletchev is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:39 PM.


Advertisement
Log in to turn off these ads.