JS获取系统的指定定年月日
/**
* 获取系统当前时间
*/
function getNowYearMouth(){
var date=new Date;
var nowYearMouth=date.getMonth()+1;
var year=date.getFullYear();
var day = date.getDate();
nowYearMouth =(nowYearMouth<10 ? "0"+nowYearMouth:nowYearMouth); //获取当前时间----月份
var nowYearMouthCur = (year.toString()+"-"+nowYearMouth.toString()); //获取当前时间----年月
var beforsixYearMouthday= getBeforeYearMouthDay();
return nowYearMouthCur;
} /**
* 获取系统当前年月日
*/
function getNowYearMouthDay(){
var date=new Date;
var nowYearMouth=date.getMonth()+1;
var year=date.getFullYear();
var day = date.getDate();
nowYearMouth =(nowYearMouth<10 ? "0"+nowYearMouth:nowYearMouth); //获取当前时间----月份
day=(day<10?"0"+day:day);
var nowYearMouthDay = (year.toString()+"-"+nowYearMouth.toString()+"-"+day.toString());//获取系统当前的年月日
return nowYearMouthDay;
} /**
* 获取系统前六个月时间--年月
*/
function getbeforeYearMouth() {
var date=new Date;
// date = new Date( date - 86400000 * 30 * 10 );
var month=date.getMonth()+1;
var year=date.getFullYear();
for (var i=0;i<6;i++)
{
if(month<=0)
{
month = month+12;
year--;
}
var tempmonth =(month<10 ? "0"+month:month);
var mydate = year.toString()+"-"+tempmonth.toString();
month--;
}
return mydate;
}
/**
* 获取系统前六个月的年月日
*/
function getBeforeYearMouthDay(){
var tempmonth;
var date=new Date;
var month=date.getMonth()+1;
var year=date.getFullYear();
var day = date.getDate();
for (var i=0;i<=12;i++){
if(month<=0) {
month = month+12;
year--;
}
tempmonth =(month<10 ? "0"+month:month);
month--;
}
if((year%100!=0)&(year%400==0)&&(year%4==0)){//是闰年的情况下
if(tempmonth==2){ //若果是2月份
if(day>29){
tempmonth = tempmonth+1;
}else{
tempmonth = tempmonth;
}
}else{//不是2月份的情况
tempmonth = tempmonth;
}
}else{//不是闰年的情况下
if(tempmonth==2){ //若果是2月份
if(day>28){
tempmonth = tempmonth+1;
}else{
tempmonth = tempmonth;
}
}else{//不是2月份的情况
tempmonth = tempmonth;
}
}
if(day<10){
day="0"+day;
}
var beforeYearMouthDay = year.toString()+"-"+tempmonth.toString()+"-"+day.toString();
return beforeYearMouthDay;
}
JS获取系统的指定定年月日的更多相关文章
- js 获取系统当前时间
JS获取当前的日期和时间的方法:var myDate = new Date();myDate.getYear(); //获取当前年份(2位)myDate.getFullYear(); //获取完整的年 ...
- js获取系统的根路径实现介绍
js如何获取系统的根路径,在本文给出了详细的方法 function getBasePath(){ var obj=window.location; var contextPath=obj.pathna ...
- js获取系统时间
//------------------------------------获取系统日期时间 var oDate=new Date(); //alert(oDate.getFullYear());// ...
- js 获取系统当前时间,判断时间大小
1.获取系统当前时间 getNowTime(tempminit) { if (!tempminit) { tempminit = 0; } var date = new Date(); date.se ...
- js 获取系统时间:年月日 星期 时分秒(动态)
最近再写一个纯html页面,有时间和天气的数据,天气后台给接口,时间要自己获取,我就自己弄了下, <div class="basic"></div> 这是放 ...
- 【转】通过js获取系统版本以及浏览器版本
function getOsInfo() { var userAgent = navigator.userAgent.toLowerCase(); var name = 'Unknown'; var ...
- js获取系统时间时自动补齐日期带零
最近在开发中发现有日期不规范的问题,正常规则应该是yy-mm-dd,而在输出时候却变成yy-mm-d,这是js的date()方法在作怪 解决思路是若在10号前,则自动给它补齐一个0,下面给出解决方法, ...
- js 获取系统时间
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- JS获取系统时间--JavaScript基础
1.网页中实时显示当前时间 <!DOCTYPE html><html lang="en"><head> <meta charset=&qu ...
随机推荐
- ios containerViewController
- (void)replaceViewController:(UIViewController *)existingViewController withViewController:(UIViewC ...
- 【bzoj1085】[SCOI2005]骑士精神
1085: [SCOI2005]骑士精神 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1757 Solved: 961[Submit][Statu ...
- tomcat与IIS在多IP服务器下的支持
同一个服务器下,双IP(或更多IP),实现tomcat与IIS公用80端口. 操作其实也很简单的,首先禁用iis的套接字池,iis绑定一个ip,然后tomcat在绑定另一个ip,最后重启下服务器即可. ...
- Unity3D的LightProbe动态光探头用法介绍
原地址:http://liweizhaolili.blog.163.com/blog/static/16230744201371721511106/ 之前曾经介绍过Unity3D的LightMappi ...
- BZOJ2961: 共点圆
好久没发了 CDQ分治,具体做法见XHR的论文… /************************************************************** Problem: 29 ...
- vi/vim使用指北 ---- Beyond the Basic
更多的组合命令 [number]-[command]-[test object] number: 数字 comand: c,d,y (修改,删除,复制) test object: 移动光标的命 ...
- [STL]heap和priority_queue
一.heap 在STL中,priority_queue(优先权队列)的底层机制是最大堆,因此有必要先来了解一下heap.heap采用完全二叉树的结构,当然不是真正的binary tree,因为对于完全 ...
- T_SQL基于列的逻辑表达式(case)
本文摘自:http://www.cnblogs.com/kissdodog/p/3154371.html(感谢作者的分享,总结的很好) 基于列的逻辑表达式,其实就是CASE表达式.可以用在SELECT ...
- 广播接收者BroadcastReceiver
BroadcastReceiver与activity,service有完整的生命周期不同,BroadcastReceiver本质上是一系统级别的监听器,专门负责监听各程序发出的broadcast.与程 ...
- hdu 4767 Bell
思路:矩阵快速幂+中国剩余定理!! 查资料得到2个公式: 1) B[n+p] = B[n] + B[n+1] mod p ; 2) B[p^m+n] = ...