thymeleaf:th:value="${#dates.format(obj.pushTime, 'yyyy-MM-dd HH:mm:ss')}
開始使用這個轉換時間 沒法顯示 可是轉換的時間是對的javascript
最後發現datetime-local的格式要求 必須是「yyyy-MM-ddTHH:mm」這種格式的,切記:日期格式必須是2019-06-27T13:30這種的,不能是2019/06/27 13:30或2019-6-27 13:30。java
<script language='javascript' th:inline="javascript"> var pushTime = t([[${obj.pushTime}]]); function t(e) { var date = new Date(); if (e != null) { date = new Date(e); } Y = date.getFullYear() + '-'; M = date.getMonth() + 1; if (M.length != 2) { M = '0' + M; } M = M + '-'; D = date.getDate() + 'T'; h = date.getHours() + ':'; m = date.getMinutes() + ''; s = date.getSeconds(); return (Y + M + D + h + m); } document.getElementById("pushTime").value = pushTime; </script>
火狐不支持datetime-local,能夠用別的。spa