js获取时间
2024-10-18 14:09:20
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();
最新文章
- Ural 1011. Conductors
- http错误码大全?
- s3c2440 移值u-boot-2016.03 第6篇 支持mtd yaffs 烧写
- hdu 1142 用优先队列实现Dijkstra
- HW5.27
- 使用 Node.js 做 Function Test
- 老李分享:jvm垃圾回收
- [leetcode-442-Find All Duplicates in an Array]
- Django进阶篇【2】
- 利用spring AOP实现每个请求的日志输出
- 一个特殊的SQL Server阻塞案例分析
- url传参过程中文字需编码、解码使用
- scott 本月报将收录移动Web加速技术的主要进展,欢迎读者一起完善,投稿邮箱:openweb@baidu.com
- 序列化与反序列化之JSON
- 解决 Ionic 浏览器跨域问题
- 【C语言天天练(三)】typedef具体解释
- IDEA破解教程
- idea中springboot项目程序入口右键不显示run as的原因
- matlab:inv,pinv逆与伪逆
- jQuery版本的jsonp
热门文章
- ubuntu上部署github博客,利用hexo
- chromium浏览器开发系列第二篇:如何编译最新chromium源码
- 智捷公开课马上开始了-欢迎大家一起讨论学习-第一系列读《Swift开发指南(修订版) 》看Swift视频教程
- iOS自定义NavigationBar
- hdu 2176 取(m)石子游戏
- Install GDAL in OpenSUSE 12.3 Linux
- JAVA多线程学习2--线程同步
- odoo8.0+PyCharm4.5开发环境配置
- SQL Server Management Studio Keyboard shortcuts
- 第六周 N题