IT Community - Software Programming, Web Development and Technical Support

convert a text string into a Date object.

This is a discussion on convert a text string into a Date object. within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; Hi all... Can any one tell me how can i convert a text string: "Wed Aug 26 14:40:...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > HTML, CSS and Javascript Coding Techniques

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 02-10-2008, 09:32 PM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 547
itbarota is on a distinguished road
Default convert a text string into a Date object.

Hi all...

Can any one tell me how can i convert a text string: "Wed Aug 26 14:40:45 MET DST 1998." into a Date object.

Thanks...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-10-2008, 09:37 PM
Pvinothkumar Pvinothkumar is offline
D-Web Analyst
 
Join Date: Sep 2007
Posts: 237
Pvinothkumar is on a distinguished road
Default Re: convert a text string into a Date object.

Hi all...


<script language="JavaScript">
var textdate = 'Wed Aug 26 14:40:45 MET DST 1998.';
var myArray = textdate.split(' ');
var input = myArray[0] + ', ' + myArray[2] + ' ' + myArray[1] + ' ' + myArray[3] + ' ' + myArray[6].substring(0,4);
var output = Date.parse(input);
var mydate = new Date(output)
</script>


Thanks...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-12-2008, 06:37 AM
GDevakii GDevakii is offline
D-Web Sr.Programmer
 
Join Date: Aug 2007
Posts: 138
GDevakii is on a distinguished road
Smile Re: convert a text string into a Date object.

<script>
d = new Date() //today's date
mill=new Date(3000, 00, 01, 00, 00, 00) //Next millennium start date
diff = mill-d //difference in milliseconds
mtg = new String(diff/86400000) //calculate days and convert to string
point=mtg.indexOf(".") //find the decimal point
days=mtg.substring(0,point) //get just the whole days
document.write("There are only " + days + " days remaining to the start of the next millennium.")
</script>
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert String to Date: new Date(string) oxygen Flash Actionscript Programming 3 03-07-2008 09:24 PM
Convert a date in milliseconds back to a date string itbarota HTML, CSS and Javascript Coding Techniques 2 03-03-2008 09:03 PM
How do I work out the date seven days before a text string mm/dd/yy? itbarota HTML, CSS and Javascript Coding Techniques 1 01-01-2008 08:42 PM
Need Help: convert string to unknown class object c#? a.deeban C# Programming 0 08-16-2007 05:18 AM
How to convert a date to a globally accepted date format, in DOT NET 2005? Archer C# Programming 1 07-25-2007 03:21 AM


All times are GMT -7. The time now is 11:25 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0