将格式数据jquery从long更改为short
change format data jquery from the long to the shortly
我想要像201507280945
这样的格式数据,而不是像Thu May 29 2014 13:50:00 GMT-0400 (Eastern Standard Time)
我把这个代码放在上
var time = new Date();
我得到这个Thu May 29 2014 13:50:00 GMT-0400 (Eastern Standard Time)
分别获取值并执行concat。
var Current = new Date();
var DD = Current.getDate();
var MM = Current.getMonth() + 1; //January is 0
var YYYY = Current.getFullYear();
var hr = Current.getHours();
var min = Current.getMinutes();
var milsec = Current.getMilliseconds();
and so on.............
如何编写自己的日期格式化程序。
function dateFormat(date) {
var hours = date.getHours();
var minutes = date.getMinutes();
var ampm = hours >= 12 ? 'pm' : 'am';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0'+minutes : minutes;
var strTime = hours + ':' + minutes + ' ' + ampm;
//below is to format to whatever you want, for example month/day/year time...
return date.getMonth()+1 + "/" + date.getDate() + "/" + date.getFullYear() + " " + strTime;
}
var dateString = formatDate(new Date());
console.log(dateString );
相关文章:
- JavaScript函数未返回谷歌地图lat/long的值
- Possibile使用Manifest v2下的HTML5地理位置API将lat/long转换为国家/地区
- 如何在文本搜索后返回long/lat
- 获取给定lat-long的javascript中的当前日期和时间
- 使用Lat Long的气泡高地图
- 仅在JS中从LAT-LONG获取大陆
- 在工作灯中的Http适配器中检索Lat和Long
- 通过它查询谷歌地图上已经存在的标记's的lat和long,并以编程方式在其上触发一个单击事件
- long polling - jquery + php
- 从SQlite中提取Lat-Long并在网络视图中显示
- anchorOffset在WebKit(chrome和safari)中是int而不是long
- 如何在谷歌地图上显示我的数据库地址,不带lat和long
- 打开图层3-将Lat Long转换为Point
- 谷歌地图方向URL与针在Lat/Long
- WebSockets, Comet, AJAX & Long Polling
- toLocaleDateString() short format
- Mongodb 在 long 中的时间戳上运行
- Angularjs long polling
- Javascript location.reload() wih JSP short url
- 将格式数据jquery从long更改为short