javascript-how add 12 hrs to 2011-5-11 03:33:43 PM

javascript-how add 12 hrs to 2011-5-11 03:33:43 PM

My date format is (yyyy-mm-dd H:I:S,)(12 hours format)
I want to add 12 hours ,24 hours,36 hours,48 hours,60 hours etc.to date.
I don't want to show it in UTC format.
please help.

<html>
<script lang='javascript'>
function addhours()
{
   var dt=document.getElementById('mydate').value.substr(0,10);
   var tme=document.getElementById('mydate').value.substr(11,8);

	arrdt= dt.split("-");
      arrtme=tme.split(":");
	newdt=new Date(arrdt[0],arrdt[1]-1,arrdt[2],arrtme[0],arrtme[1],arrtme[2]);
	alert(newdt);
      newdt.setHours(document.getElementById('myhours').value);
	alert(newdt);
//alert(dt);

//alert(tme);
}
</script>
<body>
<form id=frm name=frm>
Date: <input type=text name=mydate id=mydate value='2011-05-11 15:33:42'><br>
Add Hours: <input type=text name=myhours id=myhours value=12><br>
<input type=button onclick="addhours()">
</form>
</body>
</html>
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.