JavaScript Intl DateTimeFormat() Constructor Last Updated : 04 Apr, 2023 Comments Improve Suggest changes Like Article Like Report JavaScript Intl.DateTimeFormat Constructor is used for creating Intl.DateTimeFormat objects. This constructor can be called with or without the new keyword Syntax: Intl.DateTimeFormat(loc, opt) new Intl.DateTimeFormat(loc, opt) Parameter: This constructor has two methods and both are optional. loc: This is a String or an array of Strings with the following values allowed:nu: It Specifies the numbering system to be followedca: It specifies the calendar to be followedhc: It specifies the hour cycle format to be followedopt: This parameter contains other properties such as datestyle, timestyle, dayperiod, era etc. Returns: This returns a new DateTimeFormat object whose properties differ on whether it is called using new keyword or not. Below examples illustrate the JavaScript Intl DateTimeFormat() Constructor: Example 1: In this example, we will create a DateTimeFormat object and use it to format the date object. JavaScript const time = new Intl.DateTimeFormat("en", { timeStyle: "short", dateStyle: "short" }) var val = new Date(); console.log(time.format(val)); Output: The Date variable was formatted using the format method 4/3/23, 2:11 PM Example 2: In this example, we will format the Date object using the constructor. JavaScript var val = new Date(); console.log(new Intl.DateTimeFormat("en",{ hour: "2-digit", month: "numeric", hourCycle: "h23", dayPeriod: "long", timeZone: "GMT", }).format(val)); Output: 4, 08 Supported Browsers: ChromeEdgeFirefoxOperaSafari We have a complete list of JavaScript Intl methods to check those please go through, the JavaScript Intl Reference article. Comment More infoAdvertise with us Next Article JavaScript Intl DateTimeFormat() Constructor S shobhit_sharma Follow Improve Article Tags : JavaScript Web Technologies Similar Reads JavaScript Intl RelativeTimeFormat() Constructor JavaScript Intl RelativeTimeFormat() Constructor is used for creating Intl.RelativeTimeFormat object. This constructor is created using the new keyword. If we create the constructor without the new keyword it will give a TypeError. Syntax: new Intl.RelativeTimeFormat(loc, opt) Parameters: It has two 1 min read DateFormat Class in Java The java.text.DateFormat is an abstract class that is used to format and parse dates for any locale. It allows us to format date to text and parse text to date. DateFormat class provides many functionalities to obtain, format, parse default date/time. DateFormat class extends Format class that means 4 min read DateFormat getDateTimeInstance() Method in Java with Examples DateFormat class of java.text package is an abstract class that is used to format and parse dates for any locale. It allows us to format date to text and parse text to date. DateFormat class provides many functionalities to obtain, format, parse default date/time. Note: DateFormat class extends Form 2 min read DateFormat getTimeInstance() Method in Java with Examples DateFormat class of java.text package is an abstract class that is used to format and parse dates for any locale. It allows us to format date to text and parse text to date. DateFormat class provides many functionalities to obtain, format, parse default date/time. Note: DateFormat class extends Form 2 min read DateFormat getDateInstance() Method in Java with Examples DateFormat class of java.text package is an abstract class that is used to format and parse dates for any locale. It allows us to format date to text and parse text to date. DateFormat class provides many functionalities to obtain, format, parse default date/time. Note: DateFormat class extends Form 2 min read Like