/**
* 获取系统当前时间
*/
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. xp/2003开关3389指令

    开启3389: @echo offtitle 开启3389clsrem 开启3389reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ ...

  2. google大赛 入围赛250分真题

    Problem StatementYou have a collection of music files with names formatted as "genre-artist-alb ...

  3. Sqli-labs less 35

    Less-35 35关和33关是大致的一样的,唯一的区别在于sql语句的不同. $sql="SELECT * FROM users WHERE id=$id LIMIT 0,1"; ...

  4. swfObject 使用说明

    1.Embed your SWF with JavaScript 使用方法  swfobject.embedSWF(swfUrl, id, width, height, version, expres ...

  5. x64的调用约定

    在设计调用约定时,x64 体系结构利用机会清除了现有 Win32 调用约定(如 __stdcall.__cdecl.__fastcall._thiscall 等)的混乱.在 Win64 中,只有一个本 ...

  6. __stdcall 与 __cdecl

    (1) _stdcall调用 _stdcall是Pascal程序的缺省调用方式,参数采用从右到左的压栈方式,被调函数自身在返回前清空堆栈. WIN32 Api都采用_stdcall调用方式,这样的宏定 ...

  7. lintcode:最长公共子序列

    题目 最长公共子序列 给出两个字符串,找到最长公共子序列(LCS),返回LCS的长度. 样例 给出"ABCD" 和 "EDCA",这个LCS是 "A& ...

  8. 批处理命令 - if

    0.功能 Performs conditional processing in batch programs. 执行批处理程序中的条件处理. 1.简介 IF [NOT] ERRORLEVEL numb ...

  9. sql server UI怎么设置自增加id?

    设置表结构的时候,设置标识列就可以了啊 来自为知笔记(Wiz)

  10. Android基础之Activity launchMode详解

    本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! Activity的lauchmode,是基础的属性,但也是App优化必须掌握的知识,它约束了Acti ...