前台将sql.Timestamp的日期类型转为String

function time(timestamp) {
        var time = new Date(timestamp);
        var y = time.getFullYear();
        var m = (time.getMonth() + 1) < 10 ? "0" + (time.getMonth() + 1) : (time.getMonth() + 1);//获取当前月份的日期,不足10补0
        var d = time.getDate() < 10 ? "0" + time.getDate() : time.getDate();//获取当前几号,不足10补0s
        return y + "/" + m + "/" + d + " " + time.toTimeString().substr(0, 5);
    }

或者在前台导入<%@ taglib prefix=“fmt” uri=“http://java.sun.com/jsp/jstl/fmt” %>后

<fmt:formatDate value="${timestamp}" pattern="yyyy/MM/dd HH:mm"/></p>

猜你喜欢

转载自blog.csdn.net/DingKG/article/details/83343601
今日推荐