发表于: 2016-07-02 23:39:53
1 2614
今天完成的事情:
task5 的js部分快完成
明天计划的事情:
完成task5 去postman上测试接口
遇到的问题:
rest的部分看的有点懵逼,例子看懂了,rest接口的用处没搞明白
收获:
ajax的基本格式
$.ajax({
url:"/a/student/"+lid,
type:"PUT",
dataType:"json",
data:getData(),
success:function(){
JS中timestamp的获取与转换 timestamp时间戳
var timestamp=Math.round(new Date().getTime()/1000);
简单解释一下:
new Date() 初始化一个日期时间对象
get.Time()取毫秒数,所以要取1000
Math.round是初始化一个数学方法,类似于php的ceil方法。
timestamp转Date:
Date.prototype.format = function(format) {
var o = {
“M+”: this.getMonth() + 1,
// month
“d+”: this.getDate(),
// day
“h+”: this.getHours(),
// hour
“m+”: this.getMinutes(),
// minute
“s+”: this.getSeconds(),
// second
“q+”: Math.floor((this.getMonth() + 3) / 3),
// quarter
“S”: this.getMilliseconds()
// millisecond
};
if (/(y+)/.test(format) || /(Y+)/.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear() + “”).substr(4 - RegExp.$1.length));
}
for (var k in o) {
if (new RegExp(“(” + k + “)”).test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : (“00” + o[k]).substr((“” + o[k]).length));
}
}
return format;
};
function timestampformat(timestamp) {
return (new Date(timestamp * 1000)).format(“yyyy-MM-dd hh:mm:ss”);
}
然后感觉我自己业务逻辑比较混乱还需要好好理一下
评论