js获取时间
2016-03-31 17:18
316 查看
var myDate = new Date(); console.log(myDate.toLocaleString()); function getNowFormatDate() { var date = new Date(); console.log(date); var seperator1 = "-"; var seperator2 = ":"; var month = date.getMonth() + 1; console.log(month); var strDate = date.getDate(); console.log(strDate); if (month >= 1 && month <= 9) { month = "0" + month; console.log(month); } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; console.log(strDate); } var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate + " " + date.getHours() + seperator2 + date.getMinutes() + seperator2 + date.getSeconds(); console.log(date.getFullYear()); console.log(date.getHours()); console.log(date.getMinutes()); console.log(currentdate) ; } getNowFormatDate();
相关文章推荐
- js实现省市级三级联动
- JS 中如何判断 undefined 和 null
- Sea.js
- jsp 嵌套iframe 从iframe中表单提交并传值到外层
- JSTL 数据向上/下取整
- iscroll.js
- JAVASCRIPT闭包以及原型链
- javascript中让你捉摸不定的this
- Jstack方法
- js函数判断字符串的长度
- json的简单使用
- Javascript模块化编程(二):AMD规范
- Javascript模块化编程(一):模块的写法
- JavaScript的Tab切换
- javascript 模板引擎:artTemplate-3.0
- 【BZOJ1016】[JSOI2008]最小生成树计数【最小生成树】【搜索】
- 笔记 Json各种格式解析
- JS面向对象的程序设计
- JS input 文本框事件
- jsp page 提示[page] is not properly terminated