当前位置:网站首页>Global filter (processing time format)
Global filter (processing time format)
2022-07-01 10:56:00 【Yuzhibo Linzhong Road】
padStart() For head completion
padStart(2,'0') Convert to string '3', Less than two , Add a front 0, Output is 03, The date of complete settlement is as :2020-07-06 This kind of problem
//padStart(2,'0') Convert to string '6', Less than two , Add a front 0, Output is 06, The date of complete settlement is as :2020-07-06 This kind of problem
var month = 6;
var newMonth = (month + "").padStart(2, "0");
console.log(newMonth); //06
//padStart(3,'0') Convert to string '7', Less than three , Add a front 00, Output is 007
var day = 7;
var newDay = day.toString().padStart(3, "0");
console.log(newDay); //007padEnd() For tail completion
//padEnd(2,'0') Convert to string '6', Less than two , Add a 0, Output is 60, Not much use
var month = 6;
var newMonth = (month + "").padEnd(2, "0");
console.log(newMonth); //60
//padEnd(3,'0') Convert to string '7', Less than three , Add a 00, Output is 700, Not much use
var day = 7;
var newDay = day.toString().padEnd(3, "0");
console.log(newDay); //700 Global filter method 1:
// main.js In file
// Global filter (' The name of the filter ', Time data processed )
Vue.filter("dataFormat", (data) => {
const dt = new Date(data);
// month +1 Convert to string to process data
const y = dt.getFullYear();
const m = (dt.getMonth() + 1).toString().padStart(2, "0");
const d = dt.getDate().toString().padStart(2, "0");
const hh = dt.getHours().toString().padStart(2, "0");
const mm = dt.getMinutes.toString().padStart(2, "0");
const ss = dt.getSeconds.toString().padStart(2, "0");
return `${y}-${m}-${d} ${hh}:${mm}:${ss} `;
});边栏推荐
- Google's new paper Minerva: solving quantitative reasoning problems with language models
- NeurIPS 2022 | 细胞图像分割竞赛正式启动!
- Value 1000 graduation project campus information publishing platform website source code
- Combination of Oracle and JSON
- 106. 从中序与后序遍历序列构造二叉树
- Want to open an account, is it safe to open an account of Huatai Securities online?
- JS基础--数据类型
- The Lantern Festival is held on the fifteenth day of the first month, and the Lantern Festival begins to celebrate the reunion
- [.net6] use ml.net+onnx pre training model to liven the classic "Huaqiang buys melons" in station B
- The project bar on the left side of CodeBlocks disappears, workspace automatically saves the project, default workspace, open the last workspace, workspace (Graphic tutorial, solved)
猜你喜欢

PHP有哪些优势和劣势

SQL optimization - in and not in, exist

What legal risks and qualifications should be paid attention to when building a digital collection platform?

CRC verification

applyMiddleware 原理

Yoda unified data application -- Exploration and practice of fusion computing in ant risk scenarios

How to solve the problem of SQL?

CVPR 2022 | 基于密度与深度分解的自增强非成对图像去雾

Wireshark TS | confusion between fast retransmission and out of sequence

SQLAchemy 常用操作
随机推荐
Mutual conversion of pictures in fluent uint8list format and pictures in file format
【MPC】②quadprog求解正定、半正定、负定二次规划
LeetCode 438. 找到字符串中所有字母异位词__滑动窗口
Detailed explanation of linear regression in machine learning
[MPC] ② quadprog solves positive definite, semi positive definite and negative definite quadratic programming
prism journal导航按钮的可用性探索记录
基金国际化的发展概况
毕业季·进击的技术er
获取键代码
YoDA统一数据应用——融合计算在蚂蚁风险场景下的探索与实践
谷歌新论文-Minerva:用语言模型解决定量推理问题
CRC 校驗
Win平台下influxDB导出、导入
Simulink simulation circuit model of open loop buck buck buck chopper circuit based on MATLAB
MIT最新论文《对可解释特征的需求:动机和分类》:在机器学习模型的组成元素中建立可解释性
442. 数组中重复的数据
. Net 5.0+ does not need to rely on third-party native implementation of scheduled tasks
商城小程序源码开源版-可二开
Rising stars in Plant Sciences (rsps2022) final Science Lecture (6.30 pm)
PHP有哪些优势和劣势