How to give a specific format pattern for a date (DD/MM/YY OR MM/DD/YYYY) in JavaScript

If we want to give a specific pattern to a date like DD/MM/YYYY or MM/DD/YYYY we can use this method. Let’s break that down and see what’s going on up there. Again, we have wrapped the entire regular expression inside ^ and $, so that the match spans entire string. ( start of first subexpression. \d{1,2} matches at least 1… Continue reading How to give a specific format pattern for a date (DD/MM/YY OR MM/DD/YYYY) in JavaScript

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… Continue reading Date format using moment.js

Convert Date() to a Different Time Zone Using JavaScript

Scenario User would like to get the current date in a different time zone using JavaScript. Solution In the following code snippet, currDate variable holds the current date and time in the given time zone: var toTimeZone=”+5:30″;var tz;if(toTimeZone.search(“:”)==-1){tz=parseFloat(toTimeZone);}else{tz=parseFloat(toTimeZone.slice(0,toTimeZone.search(“:”)))+parseFloat(toTimeZone.slice(toTimeZone.search(“:”)+1)/60)}var date = new Date();var utc = date.getTime() + (date.getTimezoneOffset() * 60000);var currDate = new Date(utc + (3600000*tz));currDate = currDate.toString();var currDate… Continue reading Convert Date() to a Different Time Zone Using JavaScript

Setting a Date value in Date type custom field in NetSuite and change the timezone

When we fetch a date value format from a custom field (Type is date) we get the format as “2022-07-13T07:00:00.000Z” ISO format. we have to convert this form into M/D/YYYY format. For that use this syntax below: Module: N/format var dateNeededByNew = rec.getValue({field:date}); // 2022-07-13T07:00:00.000Zvar formattedDateString = format.format({value : dateNeededByNew,type:format.Type.DATE //If we need time also… Continue reading Setting a Date value in Date type custom field in NetSuite and change the timezone

Converting Date to d/m/yyyy format

Scenario: Convert given date to the d/m/yyyy format Solution: You need to use the module ‘N/format‘ to convert the date to different formats. format.parse method can be use for this. It parses a value from the appropriate preference format to its raw value. The appropriate preference format is the one selected in the Date Format… Continue reading Converting Date to d/m/yyyy format

Overriding Company Date Format

The administrator can specify the date format by specifying it in the general preferences. The abbreviated date format appears on reports, forms, and data-entry pages. This page is available at Setup > Company > Preferences > General Preferences But individual user can override the date format specific to the account by specifying the same in the… Continue reading Overriding Company Date Format