码迷,mamicode.com
首页 > Web开发 > 详细

JS 获取日期字符串

时间:2017-01-17 16:57:06      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:var   logs   mon   nbsp   字符串   images   tostring   技术分享   code   

效果图:

技术分享

 

代码:

 1                 var date = new Date();
 2                 var seperator1 = "-";
 3                 var seperator2 = ":";
 4                 var month = date.getMonth() + 1;
 5                 var strDate = date.getDate();
 6                 if (month >= 1 && month <= 9) {
 7                     month = "0" + month;
 8                 }
 9                 if (strDate >= 0 && strDate <= 9) {
10                     strDate = "0" + strDate;
11                 }
12                 var currentdate = date.getFullYear() + month + strDate;
13                 sweetAlert(currentdate.toString());

 

JS 获取日期字符串

标签:var   logs   mon   nbsp   字符串   images   tostring   技术分享   code   

原文地址:http://www.cnblogs.com/XYBF-Mars/p/6293700.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!