Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting month, date and year from full date

Status
Not open for further replies.

vasilek

Programmer
Jan 5, 2003
99
US
Hello. How to extract month, date and year from the date formatted 04/08/2005. Assuming date is in text field.

Thanks.
 
Code:
var dateString = document.forms['formName'].elements['fieldName'].value;
var theDate = new Date(dateString);
var theMonth = theDate.getMonth();
var theDay = theDate.getDate();
var theYear = theDate.getFullYear();

*cLFlaVA
----------------------------
[tt]a frickin' twelve-gauge, what do you think?[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Thanks you, cLFlaVA. I should've thought of this myself. Been a long time since I was programming :)

I just changed month line to:

var theMonth = theDate.getMonth()+1;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top