<script> function getLocalTime(nS) { return new Date(parseInt(nS) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日|下午|上午/g, ""); } $(".submit").click(function(){ var myDate = getLocalTime(Date.parse(new Date())/1000); //myDate即为当前时间格式为:2011-11-11 00:22:22 $("input[name=‘create_time‘]").val(myDate); return false; }); </script>
原文地址:http://my.oschina.net/jiangchike/blog/312323