分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 技术分享

JSjs获取当前时间的前一天/后一天(昨天/明天)

发布时间:2023-09-06 01:28责任编辑:白小东关键词:js
Date curDate = new Date();var preDate = new Date(curDate.getTime() - 24*60*60*1000); //前一天var nextDate = new Date(curDate.getTime() + 24*60*60*1000); //后一天

在WdatePicker中全面实行的方法

<input class="Wdate" type="text" id="date_no" onchange="onChangeDate();" name="date_no" onclick="WdatePicker({maxDate:‘%y-%M-{%d-1}‘,isShowClear:false,readOnly:true})"/>

在js中如下:

Date.prototype.format = function (format) { ???????var args = { ???????????"M+": this.getMonth() + 1, ???????????"d+": this.getDate(), ???????????"h+": this.getHours(), ???????????"m+": this.getMinutes(), ???????????"s+": this.getSeconds(), ???????????"q+": Math.floor((this.getMonth() + 3) / 3), //quarter ???????????"S": this.getMilliseconds() ???????}; ???????if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); ???????for (var i in args) { ???????????var n = args[i]; ???????????if (new RegExp("(" + i + ")").test(format)) format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? n : ("00" + n).substr(("" + n).length)); ???????} ???????return format; ???};
var curDate = new Date(); ???????????var stringDate = new Date(curDate.getTime() - 24*60*60*1000).format("yyyy-MM-dd"); ???????????$("#date_no").val(stringDate);

以上是昨天和明天的js获取方法。

JSjs获取当前时间的前一天/后一天(昨天/明天)

原文地址:http://www.cnblogs.com/lr393993507/p/7941248.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved