please help me in javascript

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Oct 2006
Posts: 11
Reputation: Mohandsa is an unknown quantity at this point 
Solved Threads: 0
Mohandsa Mohandsa is offline Offline
Newbie Poster

please help me in javascript

 
0
  #1
Apr 6th, 2007
Dear All,

i write this html to get date in this format 4/1/2007 00:00:00
but output is Sun Apr 1 00:00:00 UTC+0200 2007.
please help me to convert it to this format 4/1/2007 00:00:00 to use it in select from al DB .:lol:



<html>
<head>
<SCRIPT type="text/javascript">
function startDate()
{
var d=new Date()
var y=d.getYear()
var m=d.getMonth()+1
var day=1
var date1=m+"/"+day+"/"+y

var result = new Date(date1)
document.write(result);
}
</SCRIPT>
</head>
<body onload="startDate()" >
</body>
</html>
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 3
Reputation: richfeed is an unknown quantity at this point 
Solved Threads: 0
richfeed richfeed is offline Offline
Newbie Poster

Re: please help me in javascript

 
0
  #2
Apr 16th, 2007
The second call to new Date(..) is converting output to a UTCString.
Simply comment out the line var result=new Date(date1) and instead document.write(date1).
You might also check your script lines end with";", use var y=d.getFullYear(), and append the zero'd time portion to the "date1" string.
Last edited by richfeed; Apr 16th, 2007 at 4:45 pm. Reason: code visible
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC