JQ$(function(){ var today = new Date();//返回当前日期时间 var yyyy = today.getFullYear();//获取当前年份 var MM = today.getMonth() + 1;//因为getMonth()方法获取的是索引值,所以要+1 var dd_h5 input="dateti">
赞
踩
<input type="datetime-local" name="release_date" id="currentDate">
- $(function(){
- var today = new Date();//返回当前日期时间
- var yyyy = today.getFullYear();//获取当前年份
- var MM = today.getMonth() + 1;//因为getMonth()方法获取的是索引值,所以要+1
- var dd = today.getDate();//返回一个月中的某一天
- var hh = today.getHours();//返回小时 (0 ~ 23)
- var mm = today.getMinutes();//返回分钟 (0 ~ 59)
- MM = checkTime(MM);//调用下面的checkTime函数,设置小于10的时间数字格式,例如5秒显示成05秒
- dd = checkTime(dd);
- hh = checkTime(hh);
- mm = checkTime(mm);
- var time = yyyy + "-" + MM + "-" + dd + "T" + hh + ":" + mm;
- var dateControl = $("#currentDate");
- dateControl.val(time);
- function checkTime(i) {
- if (i < 10) {
- i = "0" + i;//这里如果是一位数则在前面添加一位0
- }
- return i;
- }
- });

注意:如何引入JQ?如何确定是否已经引入了JQ?
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
alert($);
会显示function(e,t){return new x.fn.init(e,t,r)}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。