获取当前时间及当前时间的前一天时间

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取当前时间及当前时间的前一天时间相关的知识,希望对你有一定的参考价值。

请问js如何当前时间的前一天时间
例如当前时间表是:2014-4-17 19:43:50
前一天时间表应该是:2014-4-16 19:43:50
谢谢

参考技术A <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<script>
function shownowdate(n)

var uom = new Date();
uom.setDate(uom.getDate()+n);
uom = uom.getFullYear() + "-" + (uom.getMonth()+1) + "-" + uom.getDate()+" " +uom.getHours() + ":" + uom.getMinutes()+":"+ uom.getSeconds();
of= n>0 ? '后' :'前' ;
alert( '当前时间'+ of + Math.abs(n)+'天是: '+ uom) ;

</script>
<body>
<br><a href="#" onclick="shownowdate(-1)">当前时间的前一天是</a>
<br><a href="#" onclick="shownowdate(1)">当前时间的后一天是</a>
</body>
</html>

以上是关于获取当前时间及当前时间的前一天时间的主要内容,如果未能解决你的问题,请参考以下文章

js如何去当前时间前一天的时间和后一天

js如何去当前时间前一天的时间

python获取当前时间和前一天时间

oracle获取系统日期--当前时间+前一天+当前月+前一个月

js过去前一天日期

在 Bash 中获取日期(当前时间前一天)