943,965 Members | Top Members by Rank

Ad:
Apr 6th, 2007
0

please help me in javascript

Expand Post »
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>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Mohandsa is offline Offline
11 posts
since Oct 2006
Apr 16th, 2007
0

Re: please help me in javascript

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
richfeed is offline Offline
3 posts
since Apr 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Java Script
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: I used Javascript now I cant edit my page PLEASE HELP!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC