In main.js, define a global time filter through: Vue. Filter().
the first parameter is the name of the filter, such as: dataform,
the second parameter is the processing function of the time filter: function(), which needs to specify a formal parameter: originval, which is to process the time data
to get the originval time, first update the date and pass the originval to you, that is, to get a date object of the time according to the local time
Get four digit year through getfullyear()
Get the month through getmonth(). The month starts from 1, so make it + 1
if the month is less than two digits, fill in 0 in the front by calling. Padstart (2, ‘0’). The first parameter represents the total length of the number of digits, and the second parameter is a string. If the number of digits is less than two, which string should be filled in
Get the current date through: getdate()
Get the current hour through: gethours()
Get the current minutes through: getminutes()
Get the current seconds by: getseconds()
Let the obtained date, time, minute and second be spliced into a complete date string
return ${y} - ${m} - ${D} - ${HH}: ${mm}: ${SS}
//Format time filter
vue.filter (‘dataform ‘, function (originval) {
const DT = new date (originval)
const y = dt.getFullYear()
const m = (dt.getMonth() + 1 + ‘’).padStart(2, ‘0’)
const d = (dt.getDate() + ‘’).padStart(2, ‘0’)
const hh = (dt.getHours() + ‘’).padStart(2, ‘0’)
const mm = (dt.getMinutes() + ‘’).padStart(2, ‘0’)
const ss = (dt.getSeconds() + ‘’).padStart(2, ‘0’)
return ${y}-${m}-${d} ${hh}:${mm}:${ss}
Read More:
- How to read JS file app.ux Global variables in
- This relative module was not found: * ./store in ./src/main.js
- How to get the current time in java time string
- Vue router click the menu bar and the same module reports an error Vue router.esm.js? 2215:2065 Uncaught (in promise) Error
- Time, strftime and strptime in Python
- ERROR Invalid options in vue.config.js: “plugins“ is not allowed
- Use less.js to verify and report an error in the Vue file of vscode
- After NPM run dev is running, the browser does not respond and reports an error in. / ~ / Babel loader / lib! / ~ / Vue loader / lib/ selector.js?type=script&in
- The built-in filter function in Excel can’t contain all the items
- When calling time module – time / datetime in wxPython, an error is reported. Valueerror: unknown locale: zh cn
- Vs error unresolved external symbol_ Main, the symbol in the function “int”__ cdecl invoke_ main
- How to display the Chinese name and installation time of installed software in snmp4j walk Windows
- Using global timing task cronutil in hutool tool class
- Vue element admin configure global styles
- ERROR in static/js/app.xxxxxxx.js from UglifyJs Unexpected token: operator (>)
- Idea installation vue.js After plug-in, new has no Vue component
- Error in activation of Navicat premium register
- Python global variables and global keywords
- Local date time conversion in java8
- Cannot find module ‘.. / lib / utils / unsupported. JS’ problem in installing node in centos7