|
@@ -0,0 +1,53 @@
|
|
|
+
|
|
|
+/**
|
|
|
+ * 数字保留两位小数点
|
|
|
+ * @param {number} num
|
|
|
+ * @return {string}
|
|
|
+ */
|
|
|
+export function numToFixed(num) {
|
|
|
+ if(!num) return '0.00';
|
|
|
+ num = Number(num);
|
|
|
+ return num.toFixed(2);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 日期转 年月日格式 YY-mm-dd
|
|
|
+ * @param {string} date
|
|
|
+ * @return {string}
|
|
|
+ */
|
|
|
+export function dateToYYmmdd(date) {
|
|
|
+ if(!date) return '';
|
|
|
+ return date.slice(0, 10);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 日期转 年月日格式 YY.mm.dd
|
|
|
+ * @param {string} date
|
|
|
+ * @return {string}
|
|
|
+ */
|
|
|
+export function dateToYYmmdd2(date) {
|
|
|
+ if(!date) return '';
|
|
|
+ let newDate = date.slice(0, 10);
|
|
|
+ newDate = newDate.replace(/-/g, '.');
|
|
|
+ return newDate;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 日期转 月日格式
|
|
|
+ * @param {string} date
|
|
|
+ * @return {string}
|
|
|
+ */
|
|
|
+export function dateTommdd(date) {
|
|
|
+ if(!date) return '';
|
|
|
+ return date.slice(5, 10);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 日期转 时分秒格式
|
|
|
+ * @param {string} date
|
|
|
+ * @return {string}
|
|
|
+ */
|
|
|
+export function dateToHHmmss(date) {
|
|
|
+ if(!date) return '';
|
|
|
+ return date.slice(11, 19);
|
|
|
+}
|