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>

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.