React 獲取本月第一天起始時間 00:00:00

   獲取本月第一天起始時間 00:00:00 封裝起來作法

export function getThisMonthStartTime() {
const start = new Date(new Date(new Date().setDate(1)).toLocaleDateString()).getTime() / 1000;
return start;
}

若不轉換時間軸 可以移除後面 .getTime() / 1000

在想要引用的檔案引用

import { getThisMonthStartTime } from '封裝js路徑';
console.log('本月第一天起始時間', getThisMonthStartTime())

留言

熱門文章