Date format using moment.js

MomentJS is a JavaScript library which helps in parsing, validating, manipulating and displaying date/time in JavaScript.

Its parsing allows you to parse the date in the format required. Parsing of date is available in the string, object and array.

You can use the method isValid() and check whether the date is valid or not. MomentJS also provides many parsing flags which can be used to check for date validation.

There are various methods to manipulate the Date and Time on the moment object. add, subtract, startoftime, endoftime, local, utc, utcoffset etc., are the methods available which gives details required on date/time in MomentJS.

moment.js File: Public/moment.js at main · vairamuthu1414/Public (github.com)https://github.com/vairamuthu1414/Public/blob/main/moment.js

require(['N/runtime','./moment.js'],
    (runtime, moment) => {

     var userObj = runtime.getCurrentUser();
     var DateFormat = userObj.getPreference({
name: 'DATEFORMAT'
});

     var newStartDate = moment(startDate).format(DateFormat)
     var newEndDate = moment(endDate).format(DateFormat)

    });

Leave a comment

Your email address will not be published. Required fields are marked *