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获取当前时间的前一天/后一天(昨天/明天)的更多相关文章

  1. js获取当前时间的前一天/后一天

    Date curDate = new Date();var preDate = new Date(curDate.getTime() - 24*60*60*1000); //前一天var nextDa ...

  2. [python实用代码片段]python获取当前时间的前一天,前一周,前一个月

    python获取当前时间的前一天,前一周,前一个月. 实用python的datetime.timedelta方法,避免了有的月份是30和31等不同的情况. 获取前一个月的时间,方法实现:首先datet ...

  3. java 获取当前时间,前一天时间

    java获取当前时间,并按一定格式输出 1.用Calendar获取Date Calendar calendar=Calendar.getInstance(); SimpleDateFormat for ...

  4. js 的date的format时间,获取当前时间,前一天的日期

    Date.prototype.Format = function (fmt) { //author: meizz var o = { "M+": this.getMonth() + ...

  5. python 获取当前时间及前一天时间

    import datetime from pandas.tseries.offsets import Day now_time =datetime.datetime.now()#获取当前时间 yes_ ...

  6. 分享一段php获取随意时间的前一天代码

    <?php /** * 获取给定日期的前一天 * @param string $date * @return string $yesterday */ function getYesterday ...

  7. sql 获取当前时间的前一天,不加时分秒

    select convert(datetime,convert(char(20),dateadd(day,-1,getdate()),102)) -1 为减去天数 getdate 为 获取当前时间

  8. mysql获取当前时间,前一天,后一天

    负责的项目中,使用的是mysql数据库,页面上要显示当天所注册人数的数量,获取当前的年月日,我使用的是 CURDATE(), 错误的sql语句 eg:SELECT COUNT(*) FROM USER ...

  9. nodejs 模块moment格式化时间,获取当前时间的前一天时间

    var moment = require('moment'); moment.locale('zh-cn'); var today = {}; var _today = moment(); today ...

随机推荐

  1. U转串口驱动安装

    在装有Win7 32位系统的台式机上 先卸载旧驱动,再又一次安装. 对设备管理器里的U转串口设备从本地更新驱动.选择下图文件 系统弹出红色提示框(是否安装XXXX驱动),选择安装,随后该设备由无法启动 ...

  2. 在SpringMVC中使用Jackson并格式化时间

    在spring MVC 3中,要实现REST风格的JSON服务,最简单的方式是使用 @ResponseBody 注解.该注解会自动把返回的对象,序列化为JSON. 来看一个最简单的例子.这个例子先使用 ...

  3. 从Android4.0源码中提取的截图实现(在当前activity中有效,不能全局截图)

    原文:http://blog.csdn.net/xu_fu/article/details/39268771 从这个大神的博客看到了这篇文章,感觉写的挺好的.挺实用的功能.虽然是从源码中提取的,但是看 ...

  4. Android日志监听工具logcat命令详解(转)

    Android日志系统提供了记录和查看系统调试信息的功能.日志都是从各种软件和一些系统的缓冲区中记录下来的,缓冲区可以通过logcat命令来查看和使用. 在使用logcat之前,请确保手机的USB调试 ...

  5. Apache Ant 简介和配置

    Apache Ant 简介     Apache Ant是目前事实上的Java应用的标准build脚本工具.使它大受欢迎的一个主要愿意是它的和灵活,允许程序员创建自己的Task来对Ant进行扩展.   ...

  6. LaTeX使用技巧

    使用LaTex的方法: (1)推荐一个手写公式.自动生成LaTex的网站——Web Equation. (2)如果会LaTex,可以直接用在线LaTex编辑 (3)从mathtype转换: 首先打开文 ...

  7. 层次聚类 Hierarchical Clustering

    -------------------------------- 不管是GMM,还是k-means,都面临一个问题,就是k的个数如何选取?比如在bag-of-words模型中,用k-means训练码书 ...

  8. django的数据库操作

    ORM是通过使用描述对象和数据库之间映射的元数据,将程序中的对象自动持久化到关系数据库中,ORM在业务逻辑层和数据库层之间充当了桥梁的作用. django的交互式shell python manage ...

  9. ASP.NET MVC 中使用JavaScriptResult asp.net mvc 返回 JavaScript asp.mvc 后台返回js

    return this.Content("<script>alert('暂无!');window.location.href='/Wap/Index';</script&g ...

  10. ArcEngine C++ 10 程序的运行环境,ArcEngine RT的授权

    以前我一直以为 必须安装 Arcgis Desktop才可以授权,发现我错了,原来是这个样子的. 一.安装License manager,并授权许可server.txt 当然这个license也可以安 ...