JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 2nd, 2012, 01:28 PM
thes11's Avatar
thes11 thes11 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 39 thes11 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 37 m 36 sec
Reputation Power: 1
Send a message via Skype to thes11
Post How to display date with javascript coding?

Hi there,
I am new on javascript section. Just have started to learn javascript. I am trying to coding to show date and day......
here is the code I have created. It is showing only Wednesday when I am refreshing browser.
Is there any wrong I have made? will you check please

<html>
<head><title>Date Select</title>
</head>
<body>
<script type="text/javascript">
var date=new Date();
var day=date.getDay();
if (day==0)
{
window.document.write("Sunday");
}
else if (day==1)
{
window.document.write("Monday");
}
else if (day==2)
{
window.document.write("Tuesday");
}
else if (day==3)
{
window.document.write("Wednesday");
}
else if (day==4)
{
window.document.write("Thursday");
}
else if (day==5)
{
window.document.write("Friday");
}
else if (day==6)
{
window.document.write("Saturday");
}
</script>
</body>
</html>

I am waiting for your reply
Thanks in advance

Reply With Quote
  #2  
Old October 2nd, 2012, 01:39 PM
web_loone08's Avatar
web_loone08 web_loone08 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2008
Posts: 658 web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 8 h 2 m 36 sec
Reputation Power: 69
What browser are you using; because I tested in IE, FF, and Chrome and they all show Tuesday?

Reply With Quote
  #3  
Old October 2nd, 2012, 02:29 PM
thes11's Avatar
thes11 thes11 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 39 thes11 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 37 m 36 sec
Reputation Power: 1
Send a message via Skype to thes11
Quote:
Originally Posted by web_loone08
What browser are you using; because I tested in IE, FF, and Chrome and they all show Tuesday?

I am using firefox 10.0.2 version and it is showing Wednesday.

Reply With Quote
  #4  
Old October 2nd, 2012, 04:16 PM
web_loone08's Avatar
web_loone08 web_loone08 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2008
Posts: 658 web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 8 h 2 m 36 sec
Reputation Power: 69
Well I tested in the latest version of FF, which is 15.0.1 and it displays Tuesday. You might want to check the date on your computer and see if it is set to Wednesday. Unless you have some more JS somewhere, that would be changing the day variable; then I do not know what the explanation would be.

Reply With Quote
  #5  
Old October 4th, 2012, 03:27 AM
mind_grapes mind_grapes is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 153 mind_grapes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 13 h 5 m 54 sec
Reputation Power: 4
hi,

I just checked using chrome, firefox 15.0.1 and IE8, and they all display Thursday.

I like you am new to JavaScript, but i think this code is all good.

As suggested above you may want to test the date on your computer.

Regards
MG

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > How to display date with javascript coding?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap