js获取系统时间并格式化
来源:互联网 发布:网络教学管理平台 编辑:程序博客网 时间:2024/05/16 04:15
获取系统时间,并格式化
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>js显示当前时间</title> </head> <body> <div style="width: 200px;height:200px;" onclick="getNowFormatDate();"> 显示当前时间 </div> <script type="text/javascript"> //获取当前系统时间 function getNowFormatDate() { var date = new Date(); var strMonth = date.getMonth() + 1; var strDate = date.getDate(); var strHour = date.getHours(); var strMin = date.getMinutes(); var strSec = date.getSeconds(); if (strMonth >= 1 && strMonth <= 9) { strMonth = "0" + strMonth; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } if (strHour >= 0 && strHour <= 9) { strHour = "0" + strHour; } if (strMin >= 0 && strMin <= 9) { strMin = "0" + strMin; } if (strSec >= 0 && strSec <= 9) { strSec = "0" + strSec; } var currentdate = date.getFullYear() + '-' + strMonth + '-' + strDate + ' ' + strHour + ':' + strMin + ':' + strSec; alert(currentdate); } </script> </body> </html>
显示效果
阅读全文
0 0
- js获取系统时间并格式化
- js获取时间并格式化
- 获取系统时间,并格式化
- JS获取系统当前时间并格式化输出小函数
- js如何获取当前时间 并格式化
- JS 获取当前时间并格式化
- js获取当前时间并格式化
- 通过js获取当前时间,并格式化
- Java获取系统时间并格式化输出
- JS获取(格式化)系统当前时间
- js获取系统时间并刷新
- java中获取当前系统时间,日期并格式化输出
- java中获取当前系统时间,日期并格式化输出
- java中获取当前系统时间,日期并格式化输出
- c++/c获取系统时间,并格式化输出
- C语言获取系统时间并格式化输出
- Java获取当前的系统时间并格式化输出
- 【VB】获取系统当前时间并格式化输出
- 使用Spring Data Redis 实现订阅/发布
- linux中使用jmeter进行压力测试执行篇及遇到的问题
- UART串口简介
- 最大子序列和问题及其起始位置
- 运行时权限
- js获取系统时间并格式化
- 共享单车接入百度地图,科技进步为“国民素质”背书
- linux下文件夹的创建、复制、剪切、重命名、清空和删除的命令
- Teams 的今生前世
- hibernate详解1
- 【正则表达式】python re模块用法总结
- HDU 4886 TIANKENG’s restaurant(Ⅱ) (枚举 哈希)
- tensorflow学习之路(2-2):tf.variable_scope(),tf.name_scope(),tf.get_variable()的认识(补充)
- Teams的定义