JSjs获取当前时间的前一天/后一天(昨天/明天)
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获取当前时间的前一天/后一天(昨天/明天)的更多相关文章
- js获取当前时间的前一天/后一天
Date curDate = new Date();var preDate = new Date(curDate.getTime() - 24*60*60*1000); //前一天var nextDa ...
- [python实用代码片段]python获取当前时间的前一天,前一周,前一个月
python获取当前时间的前一天,前一周,前一个月. 实用python的datetime.timedelta方法,避免了有的月份是30和31等不同的情况. 获取前一个月的时间,方法实现:首先datet ...
- java 获取当前时间,前一天时间
java获取当前时间,并按一定格式输出 1.用Calendar获取Date Calendar calendar=Calendar.getInstance(); SimpleDateFormat for ...
- js 的date的format时间,获取当前时间,前一天的日期
Date.prototype.Format = function (fmt) { //author: meizz var o = { "M+": this.getMonth() + ...
- python 获取当前时间及前一天时间
import datetime from pandas.tseries.offsets import Day now_time =datetime.datetime.now()#获取当前时间 yes_ ...
- 分享一段php获取随意时间的前一天代码
<?php /** * 获取给定日期的前一天 * @param string $date * @return string $yesterday */ function getYesterday ...
- sql 获取当前时间的前一天,不加时分秒
select convert(datetime,convert(char(20),dateadd(day,-1,getdate()),102)) -1 为减去天数 getdate 为 获取当前时间
- mysql获取当前时间,前一天,后一天
负责的项目中,使用的是mysql数据库,页面上要显示当天所注册人数的数量,获取当前的年月日,我使用的是 CURDATE(), 错误的sql语句 eg:SELECT COUNT(*) FROM USER ...
- nodejs 模块moment格式化时间,获取当前时间的前一天时间
var moment = require('moment'); moment.locale('zh-cn'); var today = {}; var _today = moment(); today ...
随机推荐
- script标签加载顺序(defer & async)
script 拥有的属性 async:可选,表示应该立即下载脚本,但不应妨碍页面中的其他操作,比如下载其他资源或等待加载其他脚本.只对外部脚本文件有效. charset:可选.表示通过 src 属性指 ...
- 破产姐妹第六季/全集2 Broke Girls迅雷下载
英文全名2 Broke Girls,第6季(2016)CBS. 本季看点:<破产姐妹>第五季季终集达到了收视人数699万收视率1.7.在第五季终集,两姐妹发现Han(马修·摩伊 饰)的生活 ...
- 女子监狱第一季/全集Orange Is the New Black迅雷下载
本季第一季 Orange Is the New Black 1 (2013) 看点:该剧描述主人公Piper Chapman(Taylor Schilling)在大学里结识了毒贩Alex(Laura ...
- Js与正则表达式
原本接着上面的章节,这一章节应该是写 Jquery事件的,由工作需要,暂时横插一篇正则表达式的学习,这里是边学边记录,错误之处,希望指正,提拔一二,不甚感激! 此章节有 1.1 正则表达式的定义 1. ...
- html效果增强
1:提示框 http://keleyi.com/keleyi/phtml/jqplug/ 2:loading效果 <script>function showPage(){ $('#d ...
- C#多线程读写同一文件处理
在多线程访问读写同一个文件时,经常遇到异常:“文件正在由另一进程使用,因此该进程无法访问此文件”. 多线程访问统一资源的异常, 解决方案1,保证读写操作单线程执行,可以使用lock 解决方案2,使用S ...
- Asp.Net 获取物理路径
一.AppDomain 1.AppDomin获取当前前程序域目录 2.不需要请求上线文实例,例如在Global.ascx中访问等 //网站物理目录 AppDomain.CurrentDomain.Ba ...
- 【Java并发】JUC—ReentrantReadWriteLock有坑,小心读锁!
好长一段时间前,某些场景需要JUC的读写锁,但在某个时刻内读写线程都报超时预警(长时间无响应),看起来像是锁竞争过程中出现死锁(我猜).经过排查项目并没有能造成死锁的可疑之处,因为业务代码并不复杂(仅 ...
- Unicode 和 UTF-8 的区别
作者:于洋链接:https://www.zhihu.com/question/23374078/answer/69732605来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出 ...
- window.name实现的跨域数据传输 JavaScript跨域总结与解决办法
原文地址: http://www.cnblogs.com/rainman/archive/2011/02/20/1959325.html#m4 什么是跨域 1.document.domain+ifr ...