js 如何对时间处理
在第一个文本框里 选择时间 2012-5-8,然后下一个 文本框里自动显示 2012-4-8.
即,月份减一,这怎么实现啊?
求代码.求指点.
------解决方案--------------------
<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="gb2312" />
		<title></title>	
	</head>
	<body>
		<input type="" id="a" value="2012-1-8" />
		<input type="" id="b" value="" />
		<script>
			function $(el){
				return typeof el == 'string' ? document.getElementById(el) : el;
			}
			var v = $('a').value.replace(/-/g, '/');			
			var d = new Date(v);
			d.setMonth( d.getMonth() - 1 );
			$('b').value = d.getFullYear() + '-' + (+d.getMonth() + 1) + '-' + d.getDate();
		</script>
	</body>
</html>