/**
*获取当前时间
*format=1精确到天
*format=2精确到分
*/
function getCurrentDate(format) {
var now = new Date();
var year = now.getFullYear(); //得到年份
var month = now.getMonth();//得到月份
var date = now.getDate();//得到日期
var day = now.getDay();//得到周几
var hour = now.getHours();//得到小时
var minu = now.getMinutes();//得到分钟
var sec = now.getSeconds();//得到秒
month = month + 1;
if (month < 10) month = "0" + month;
if (date < 10) date = "0" + date;
if (hour < 10) hour = "0" + hour;
if (minu < 10) minu = "0" + minu;
if (sec < 10) sec = "0" + sec;
var time = "";
//精确到天
if(format==1){
time = year + "-" + month + "-" + date;
}
//精确到分
else if(format==2){
time = year + "-" + month + "-" + date+ " " + hour + ":" + minu + ":" + sec;
}
return time;
}
alert(getCurrentDate(2));

  

最新文章

  1. java基础算法之快速排序
  2. pptv泥够了!pptv“关闭”事件为营销炒作坐实!
  3. 【Web】URI和URL,及URL的编码
  4. 记一次ganglia的故障分析 mem_report不显示
  5. windows2003开启vpn服务
  6. 微信端应用 ionic实现texarea 自适应高度
  7. Online Object Tracking: A Benchmark 翻译
  8. A+B问题 涉及EOF
  9. jQuery设计思想
  10. 每天一道LeetCode--237.Delete Node in a Linked List
  11. Office 365 – Exchange Online examples
  12. 二维离散平稳小波分解swt2
  13. api接口json串换行
  14. 快速找到Office应用程序安装路径
  15. 事件的preventDefault方法
  16. KVM管理平台openebula安装
  17. lightoj 1025 区间dp
  18. django——url(路由)配置
  19. input上传文件个数控制
  20. CString、string、const char*的相互转换

热门文章

  1. gradlew tasks
  2. 无法远程连接阿里云的Mysql
  3. css(4)
  4. html5--2.9新的布局元素(6)-figure/figcaption
  5. python3 - 写一个生成双色球号码的一个程序,生成的号码写到文件里面
  6. C语言的内存四区模型和函数调用模型
  7. [CTSC 2012] Cheat
  8. AtCoder Regular Contest 080 E:Young Maids
  9. BZOJ4571:[SCOI2016]美味
  10. CF 504 E —— Misha and LCP on Tree —— 树剖+后缀数组