文章目錄
- 一、 關于 RangePicker 組件返回的moment 方法示例
一、 關于 RangePicker 組件返回的moment 方法示例
moment方法中日后開發有用的方法如下:
form.getFieldsValue().date[0].weeksInWeekYear(),form.getFieldsValue().date[0].zoneName(), form.getFieldsValue().date[0].zoneAbbr(), form.getFieldsValue().date[0].add(),form.getFieldsValue().date[0].calendar(), // 獲取時間的格式化字符串form.getFieldsValue().date[0].format('YYYY-MM-DD HH:mm:ss'), // 格式化時間form.getFieldsValue().date[0].daysInMonth(), // 獲取月份的天數form.getFieldsValue().date[0].clone(), // moment 函數本體,form.getFieldsValue().date[0].creationData(),// 創建時間,form.getFieldsValue().date[0].date(),form.getFieldsValue().date[0].eraName(),// (Anno Domini 簡寫 公元的意思 2030-03-15 14:26:00 )(before christ簡寫 BC 公元前 0000-01-13 00:00:00)// 以當前時間為準選擇的時間,比如當前是2025年 選擇的時間是2026年這是1年后 返回的數據是(1年后) 若選擇的時間是2024年 則返回的數據是(1年前)form.getFieldsValue().date[0].from(),// 相對于當前時間的描述,比如剛剛,1分鐘前,1小時前,昨天,前天,兩天或者三天前等form.getFieldsValue().date[0].fromNow(),form.getFieldsValue().date[0].isDST(), // 當前日期的時間戳 moment("2025-01-01T14:47:22.326")form.getFieldsValue().date[0].isLeapYear(), // 選擇的時間是否是前/上一年form.getFieldsValue().date[0].isLocal(), // 是否是本地時間form.getFieldsValue().date[0].isSame(), // 是否是當前時間form.getFieldsValue().date[0].isSameOrAfter(), // 是否是當前時間或者之后form.getFieldsValue().date[0].isSameOrBefore(),// 是否是當前時間或者之前form.getFieldsValue().date[0].isUTC(),// 是否是全球統一的時間form.getFieldsValue().date[0].isUtcOffset(),// 時區是否是UTCform.getFieldsValue().date[0].isValid(), // 是否是有效的時間form.getFieldsValue().date[0].isoWeek(), // 是否是 ISO 8601 格式的周數form.getFieldsValue().date[0].isoWeekYear(), // ISO 8601 格式的年份form.getFieldsValue().date[0].isoWeekday(), // ISO 8601 格式的星期幾form.getFieldsValue().date[0].isoWeeks(), //ISO 8601 當前選中的是第幾周form.getFieldsValue().date[0].isoWeeksInISOWeekYear(), // ISO 8601 格式的年份的周數form.getFieldsValue().date[0].isoWeeksInYear(), // 年份的周數form.getFieldsValue().date[0].months(), // 當前選中的是第幾月/*** parsingFlags() 返回一個對象,包含解析日期字符串的相關信息。* "empty": false,"unusedTokens": [],"unusedInput": [],"overflow": -2,"charsLeftOver": 0,"nullInput": false,"invalidEra": null,"invalidMonth": null,"invalidFormat": false,"userInvalidated": false,"iso": false,"parsedDateParts": [],"era": null,"meridiem": null,"rfc2822": false,"weekdayMismatch": false**/form.getFieldsValue().date[0].parsingFlags(),form.getFieldsValue().date[0].to(),//當前時間是2025年一月14 選擇的是2023-04-22 返回值 2 年后form.getFieldsValue().date[0].toArray(),form.getFieldsValue().date[0].toDate(), // 時間戳form.getFieldsValue().date[0].toISOString(), // 時間戳form.getFieldsValue().date[0].toJSON(), // 時間戳form.getFieldsValue().date[0].toNow(), //當前時間是2025年一月14 選擇的是2027-04-22 返回值 2 年前form.getFieldsValue().date[0].toObject(), // 時間對象 { years: 2, months: 4, date: 22, hours: 0, minutes: 0, seconds: 0, milliseconds: 0 }form.getFieldsValue().date[0].toString(), // 時間戳form.getFieldsValue().date[0].unix(), // unix時間戳是從1970年1月1日(UTC/GMT的午夜)開始所經過的秒數,不考慮閏秒,以秒為單位 時間戳form.getFieldsValue().date[0].valueOf(), // unix時間戳是從1970年1月1日(UTC/GMT的午夜)開始所經過的秒數,不考慮閏秒,以秒為單位 時間戳form.getFieldsValue().date[0].weeks(), // unix時間戳是從1970年1月1日(UTC/GMT的午夜)開始所經過的秒數,不考慮閏秒,以秒為單位 時間戳form.getFieldsValue().date[0].weekYear(), // 選擇的年份form.getFieldsValue().date[0].weekday(), // 選擇的周幾form.getFieldsValue().date[0].zoneName(), // 選擇的周幾