关于从数据库读取datetime类型数据传到前端出现格林威治(GMT)格式的转换

    技术2022-07-10  150

    MYSQL数据库中的时间是这样的格式: 但是从前端读取后呈现出来是这样的: 一种比较简单的做法是直接在前端进行修改呈现数据的样式 1.在数据展示jsp添加标签:

    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

    2.在显示时间类型的数据添加: (这里的book.bookPublish是我要展示的时间)

    <fmt:formatDate type="date" value="${book.bookPublish}" />

    其中type可指定格式: <fmt:formatDate value="<%=new Date() %>" type=“both”/>2011-3-30 9:41:21 <fmt:formatDate value="<%=new Date() %>" type=“date”/> 2011-3-30 <fmt:formatDate value="<%=new Date() %>" type=“time”/> 9:44:44

    最后问题就解决了! Reference:https://blog.csdn.net/lidawei201/article/details/7197834

    Processed: 0.009, SQL: 9