Open In App

Moment.js isDSTShifted() Function

Last Updated : 20 Mar, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

It is used to check daylight saving time-shifted in Node.js using the isDSTShifted() function. Another important thing is to know if the date has been moved by a DST. 

Syntax:

moment('2013-03-10 2:30', 'YYYY-MM-DD HH:mm').isDSTShifted()

Parameter: No parameters are required. 

Returns: True or False 

Installation of moment module:

You can visit the link to Install moment module. You can install this package by using this command.

npm install moment

After installing the moment module, you can check your moment version in the command prompt using the command.

npm version moment

After that, you can just create a folder and add a file, for example, index.js. To run this file you need to run the following command.

node index.js

Project Structure:

Example 1: Filename: index.js 

javascript




// Requiring module
const moment = require('moment');
 
let value = moment(moment()).isDSTShifted()
console.log(value);


Steps to run the program:

Make sure you have installed the moment module using the following command:

npm install moment

Run the index.js file using the below command:

node index.js

Output:

false

Example 2: Filename: index.js 

javascript




// Requiring module
const moment = require('moment');
 
function CheckIsDSTShifted(date) {
    return moment(date).isDSTShifted();
}
 
console.log(CheckIsDSTShifted(moment());


Steps to run the program:

Run the index.js file using the below command:

node index.js

Output:

false

Reference: https://momentjs.com/docs/#/query/is-dst-shifted/


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads