六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 52|回复: 0

javascript初始化时间

[复制链接]

升级  80%

10

主题

10

主题

10

主题

童生

Rank: 1

积分
40
 楼主| 发表于 2013-1-29 09:06:31 | 显示全部楼层 |阅读模式
<script type="text/javascript"> function init(){    var tempDate = new Date();    var currDate = ChangeDateToString(tempDate);    var startDate = document.getElementById("queryStartDate");    var endDate =document.getElementById("queryEndDate");    startDate.value = currDate;    endDate.value = currDate; } function ChangeDateToString(DateIn){       var Year = 0;       var Month = 0;       var Day = 0;            var CurrentDate = "";                      //初始化时间        Year  = DateIn.getYear();        Month  = DateIn.getMonth()+1;        Day  = DateIn.getDate();             CurrentDate = Year + "-";        if (Month >= 10 ){            CurrentDate = CurrentDate + Month + "-";        } else{            CurrentDate = CurrentDate + "0" + Month + "-";        }        if (Day >= 10 ){            CurrentDate = CurrentDate + Day ;        } else{            CurrentDate = CurrentDate + "0" + Day ;        }           return CurrentDate;    }   </script> 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表