Convert the front-end time format 2023-03-18T22:42:48.000+00:00 into normal format

Method 1
Front-end display: 2023-03-18T22:42:48.000+00:00
Entity classes plus annotations

 @JsonFormat(shape=JsonFormat.Shape.STRING,pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date interveneStartdate;//干预开始时间

After adding it, you can see the time displayed on the front end as 2023-03-18 22:42:48

Note that if the display modification is performed on the edit page, the time types of the front and back ends must be consistent, for example: date and datetime, the time precision of the two of them is different, date finds the year, month, and day, and datetime has the accuracy of the year, month, day, hour, minute, and second. That is, the two date types are inconsistent. If the front end is date and the back end is datetime, a type error will be reported when modifying. Just change it according to your own needs.

Method 2:
Convert after passing in parameters at the front end

    function renderTime(date) {
        var dateee = new Date(date).toJSON();
        return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
    }

Guess you like

Origin blog.csdn.net/JSUITDLWXL/article/details/129768176