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 ...
随机推荐
- U转串口驱动安装
在装有Win7 32位系统的台式机上 先卸载旧驱动,再又一次安装. 对设备管理器里的U转串口设备从本地更新驱动.选择下图文件 系统弹出红色提示框(是否安装XXXX驱动),选择安装,随后该设备由无法启动 ...
- libcurl下载文件
一.初始化 CURL *pHandler = curl_easy_init(); 二.设置请求参数: 调用curl_easy_setopt方法,设置选项 curl_easy_setopt(pHan ...
- RecyclerView常见问题解决方案,RecyclerView嵌套自动滚动,RecyclerView 高度设置wrap_content 无作用等问题
1,ScrollView或者RecyclerView1 嵌套RecyclerView2 进入页面自动跳转到recyclerView2上面页面会自动滚动貌似是RecyclerView 自动获得了焦点两 ...
- [C#技术] DataSet(DataTable)轻松的通过Sum、Aver、Count等统计出相关结果
我们在使用Sql ******这些数据库时,可以轻松的通过Sum.Aver.Count等统计出相关结果,那么,在已经把数据检索出来的DataSet(DataTable)中呢?特别是通过Web Serv ...
- 局部响应归一化(Local Response Normalization,LRN)
版权声明:本文为博主原创文章,欢迎转载,注明地址. https://blog.csdn.net/program_developer/article/details/79430119 一.LRN技术介 ...
- sugar crm
百度百科:http://baike.baidu.com/link?url=7SnriwrF-4LcRfXctBbZjLc-UEUqWl3b0YR004pGFk4SJ1qMU9TMj37yFmHRsUS ...
- APPLE框架之高效便捷的Repository解决方案
原文地址:http://perfy315.iteye.com/blog/1460226 Spring Data JPA 转至:http://note.sdo.com/u/855924134/n/P15 ...
- STM32学习笔记之EXTI(外部中断)
參考资料:STM32数据手冊.网络资料 =========================================切割线==================================== ...
- .Net-using-Class:MemoryCache 类
ylbtech-.Net-using-Class:MemoryCache 类 初始化 System.Runtime.Caching.MemoryCache 类的新实例. 1. 程序集 System.R ...
- DatabaseMirroring搭建
1. 概述 数据库镜像维护一个数据库的两个副本,这两个副本必须驻留在不同的 SQL Server 数据库引擎 服务器实例上.通常,这些服务器实例驻留在不同位置的计算机上.启动数据库上的数据库镜像 ...