About the moment time zone?

moment.js used in vue"s project. However, there is a time zone problem. The backend has dealt with the time and added another 8 hours when using moment. I would like to ask how to modify it. The following figure

clipboard.png

this is the code for template

<el-table-column prop="type" label="" align="center">
    <template slot-scope="scope">
      <span>{{scope.row.EndDate | moment("YYYY-MM-DD")}}</span>
    </template>
  </el-table-column>

introduction in main.js

Vue.use(require("vue-moment"));

would like to ask how the boss needs to change. Thank you very much

Apr.01,2022

what's wrong with it

clipboard.png


Why does the backend deal with the time zone? Can't you either process it directly into a good string of format , or just hand over the UTC time to the front end?

moment(data).utc().format('YYYY-MM-DD HH:mm:ss')

although you can get the time you want through this processing, the reason is that the time provided by the backend is incorrect


this is not a problem with moment.js, is it?
moment (). Format () you can see if it is the same as your current system time.
check whether the date time zone of the backend is set to UTC


although the background has been converted, it is not easy to deal with the converted time format on the foreground. Of course, it is convenient to use plug-ins
1 because UTC time is returned (specifically define shift what is UTC time? ), so there is jet lag. The actual time should be UTC + current time difference

2 after knowing the first point, moment.js will naturally be parsed according to the UTC time given by you, and will naturally be + 8 hours. Of course, you can only display UTC without changing regions

as you do @ asseek.

so the code is fine, and the result of the display depends on your requirements. If you need to let users calculate the jet lag themselves, then using UTC is fine

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2bb33-2ba9c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2bb33-2ba9c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?