它用於使用isDST()函數在Moment.js中檢查夏令時。此函數檢查當前時刻是否為夏令時。
用法:
moment().isDST();
參數:無需參數。
返回:對或錯
力矩模塊的安裝:
- 您可以訪問“安裝力矩”模塊的鏈接。您可以使用此命令安裝此軟件包。
npm install moment
- 安裝力矩模塊後,可以使用命令在命令提示符下檢查力矩版本。
npm version moment
- 之後,您可以僅創建一個文件夾並添加一個文件,例如index.js。要運行此文件,您需要運行以下命令。
node index.js
範例1: 文件名:index.js
// Requiring module
const moment = require('moment');
// false, March 12 2011 is not DST
var bool = moment([2011, 2, 12]).isDST();
console.log(bool);
運行程序的步驟:
- 項目結構將如下所示:
- 確保使用以下命令安裝了moment模塊:
npm install moment
- 使用以下命令運行index.js文件:
node index.js
輸出:
false
範例2: 文件名:index.js
// Requiring module
const moment = require('moment');
function checkDST(date) {
return moment(date).isDST();
}
var bool = checkDST([2011, 2, 12]);
console.log(bool);
使用以下命令運行index.js文件:
node index.js
輸出:
false
參考: https://momentjs.com/docs/#/query/is-daylight-saving-time/
相關用法
- d3.js d3.map.set()用法及代碼示例
- PHP Ds\Map xor()用法及代碼示例
- PHP min( )用法及代碼示例
- p5.js box()用法及代碼示例
- p5.js nfc()用法及代碼示例
- CSS url()用法及代碼示例
- p5.js nf()用法及代碼示例
- PHP Ds\Map get()用法及代碼示例
- PHP max( )用法及代碼示例
- PHP each()用法及代碼示例
- PHP key()用法及代碼示例
- d3.js d3.hsl()用法及代碼示例
- PHP pos()用法及代碼示例
- PHP end()用法及代碼示例
- CSS var()用法及代碼示例
注:本文由純淨天空篩選整理自gouravhammad大神的英文原創作品 Moment.js isDST() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。