/**
* 获取系统当前时间
*/
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. ios UI实现技巧

    statusBar 移动位置 NSString *key = [[NSString alloc] initWithData:[NSData dataWithBytes:(unsigned ] enco ...

  2. css选择器浏览器支持情况

    css选择器浏览器支持情况

  3. 利用Jquery实现http长连接(LongPoll) {转}

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="JqueryAjaxLongPo ...

  4. javascript实现数据结构:串--定长顺序存储表示以及kmp算法实现

    串(string)(或字符串)是由零个或多个字符组成的有限序列.串中字符的数目称为串的长度.零个字符的串称为空串(null string),它的长度为零. 串中任意个连续的字符组成的子序列称为该串的子 ...

  5. Level2行情和传统行情的区别

    序号 Level2行情 传统行情 Level 2特点 Level 2行情优势 1 每3秒钟发送一次行情信息 每6秒钟发送一次 行情显示速度更快 投资者更及时地获得交易信息 2 证券逐笔成交明细信息 证 ...

  6. ASP.NET母版页与内容页相对路径的问题

    1. 图片问题 图片显示问题:<img runat="server" src="~/images/ad468x60.gif" alt="&quo ...

  7. 翻译 - 元编程动态方法之public_send

    李哲 - MAY 20, 2015 原文地址:Metaprogramming Dynamic Methods: Using Public_send 作者:Friends of The Web的开发者V ...

  8. Java package详解

    Java引入包(package)机制,提供了类的多层命名空间,用于解决类的命名冲突.类文件管理等问题.Java允许将一组功能相关的类放在同一个package下,从而组成逻辑上的类库单元.如果希望把一个 ...

  9. java 静态构造函数

    在java中貌似是没有静态构造函数的. 不过用下面的方式同样可以实现效果. static { }//end 这是静态代码块

  10. VulToEs

    VulntoES https://github.com/ChrisRimondi/VulntoES