Solved

How to get the day name from this date format (23-Aug-2010) in java script?

Posted on 2010-08-18
5
354 Views
Last Modified: 2012-05-10
Hello please give the solution for this
0
Comment
Question by:rite2mis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 23

Expert Comment

by:Kamaraj Subramanian
ID: 33466233
0
 
LVL 23

Expert Comment

by:Kamaraj Subramanian
ID: 33466266
Just replace the - with " " (space) and pass it to the below javascript

http://www.trans4mind.com/personal_development/JavaScript/time2.htm
function getTheDay(aText)

{

myDays= 

["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]

myDate=new Date(eval('"'+aText.value+'"'))

document.form1.textDay.value=myDays[myDate.getDay()]

}

Open in new window

0
 
LVL 23

Expert Comment

by:Kamaraj Subramanian
ID: 33466536
here is the full code.. just try it out
<script type="text/javascript">

<!--//

function getTheDay(aText)

{

myDays= 

["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]

myDate=new Date(eval('"'+aText.value.replace("-"," ") +'"'))

document.form1.textDay.value=myDays[myDate.getDay()]

}

//-->

</script>

<form name="form1" id="form1" method="post" action="" enctype="text/plain">

<input type="text" name="textDate" id="textDate" value="23-Aug-2010" size="25" maxlength="25" />

<input type="button" value="Get day of week" onclick="getTheDay(this.form.textDate)" />

<small>

Day of week appears here

</small>

<br />

<input type="text" name="textDay" VALUE size="25" maxlength="25" />

<br />

</form>

Open in new window

0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 25 total points
ID: 33466806
no need for eval

new Date(aText.value.replace(/\-/g," "))



0
 

Author Closing Comment

by:rite2mis
ID: 33498452
nice replies
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
I need to make my existing Javascript Menu conditional within my ASP.Net/C# Application 32 37
Html split(text) Part2 6 25
Compute age Html 2 27
HTML editor custom button 3 60
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question