/**
* 获取系统当前时间
*/
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获取系统的指定定年月日的更多相关文章

  1. js 获取系统当前时间

    JS获取当前的日期和时间的方法:var myDate = new Date();myDate.getYear(); //获取当前年份(2位)myDate.getFullYear(); //获取完整的年 ...

  2. js获取系统的根路径实现介绍

    js如何获取系统的根路径,在本文给出了详细的方法 function getBasePath(){ var obj=window.location; var contextPath=obj.pathna ...

  3. js获取系统时间

    //------------------------------------获取系统日期时间 var oDate=new Date(); //alert(oDate.getFullYear());// ...

  4. js 获取系统当前时间,判断时间大小

    1.获取系统当前时间 getNowTime(tempminit) { if (!tempminit) { tempminit = 0; } var date = new Date(); date.se ...

  5. js 获取系统时间:年月日 星期 时分秒(动态)

    最近再写一个纯html页面,有时间和天气的数据,天气后台给接口,时间要自己获取,我就自己弄了下, <div class="basic"></div> 这是放 ...

  6. 【转】通过js获取系统版本以及浏览器版本

    function getOsInfo() { var userAgent = navigator.userAgent.toLowerCase(); var name = 'Unknown'; var ...

  7. js获取系统时间时自动补齐日期带零

    最近在开发中发现有日期不规范的问题,正常规则应该是yy-mm-dd,而在输出时候却变成yy-mm-d,这是js的date()方法在作怪 解决思路是若在10号前,则自动给它补齐一个0,下面给出解决方法, ...

  8. js 获取系统时间

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. JS获取系统时间--JavaScript基础

    1.网页中实时显示当前时间 <!DOCTYPE html><html lang="en"><head> <meta charset=&qu ...

随机推荐

  1. HDOJ 1709 The Balance(母函数)

    The Balance Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  2. Sqli-labs less 31

    Less-31 Less-31与上述两个例子的方式是一样的,我们直接看到less-31的sql语句: 所以payload为: http://127.0.0.1:8080/sqli-labs/Less- ...

  3. .net 类型源码下载地址

    原文:http://www.cnblogs.com/ProJKY/p/SSCLI.html 一般场景下,采用 Reflector可以反射出.NET 的部分实现出来,可以拿来参考,但和微软公开的SSCL ...

  4. POJ 2010

    Moo University - Financial Aid Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 4235   A ...

  5. POJ 1273 Drainage Ditches(网络流dinic算法模板)

    POJ 1273给出M条边,N个点,求源点1到汇点N的最大流量. 本文主要就是附上dinic的模板,供以后参考. #include <iostream> #include <stdi ...

  6. Git 10 周年之际,创始人 Linus Torvalds 访谈

    点这里 十年前的这一周,linux 内核社区面临一个根本性的挑战:他们不再能够使用他们的修复控制系统:BitKeeper,同时其他的软件配置管理遇到了对分布式系统的新需求.Linus Torvalds ...

  7. MYSQL判断某个表是否已经存在

    方法一.You don't need to count anything. SELECT 1 FROM testtable LIMIT 1; If there's no error, table ex ...

  8. lightoj 1397 - Sudoku Solver

    思路:每次找出可能情况最少的位置枚举可能情况!!! poj2676和这题一样不过poj数据比较水,很容易过. 代码如下: #include<iostream> #include<cs ...

  9. zoj 2290 Game 博弈论

    思路:HDU有过类似的题目,也就是谁面对FIB数,就处于必败状态. 再求第二问的时候要注意不一定要在一步之内就让对手处于必败状态,可以多步进行, 这个过程可以用递归实现. 代码如下: #include ...

  10. UVA 10574 - Counting Rectangles 计数

    Given n points on the XY plane, count how many regular rectangles are formed. A rectangle is regular ...