使用ohpm install下載
1续语、ArkTS時間格式轉換
下載安裝
ohpm install dayjs
導入使用
import dayjs from "dayjs";
示例代碼
參數(shù)類型:Date土榴、string
dayjs(參數(shù)); // 解析
當前時間:dayjs().format(“YYYY-MM-DD HH:mm:ss”)
某個date: dayjs(參數(shù)).format(“YYYY-MM-DD HH:mm:ss”)
dayjs().set("month", 3).month(); // 獲取
dayjs().add(1, "year"); // 處理
dayjs().isBefore(dayjs()); // 查詢
開源站點部分API使用方法不明
可以查看https://day.js.org/docs/en/display/difference