- ✕Tá an achoimre seo ginte ag intleacht shaorga atá bunaithe ar roinnt foinsí ar líne. Úsáid na naisc "Foghlaim tuilleadh" chun amharc ar an mbunfhaisnéis fhoinseach.
Creating dates in JavaScript can be done using the Date object. The Date object provides various constructors to create date instances.
Example
// Current date and timeconst now = new Date();console.log(now); // Outputs current date and time// Specific date and timeconst specificDate = new Date("December 17, 1995 03:24:00");console.log(specificDate); // Outputs: Sun Dec 17 1995 03:24:00 GMT// Using year, month, day, hours, minutes, seconds, millisecondsconst detailedDate = new Date(2022, 11, 24, 10, 33, 30, 0);console.log(detailedDate); // Outputs: Sat Dec 24 2022 10:33:30 GMTCóipeáilte!✕CóipeáilUsing Different Constructors
No Parameters: Creates a date object with the current date and time. const currentDate = new Date();
Date String: Creates a date object from a date string. const dateString = new Date("October 13, 2014 11:13:00");
Year and Month: Creates a date object with a specified year and month. const yearMonth = new Date(2022, 11); // December is month 11 (0-indexed)
Year, Month, Day: Creates a date object with specified year, month, and day. const yearMonthDay = new Date(2022, 11, 24);
Year, Month, Day, Hours: Creates a date object with specified year, month, day, and hours. const yearMonthDayHour = new Date(2022, 11, 24, 10);
Year, Month, Day, Hours, Minutes: Creates a date object with specified year, month, day, hours, and minutes. const yearMonthDayHourMinute = new Date(2022, 11, 24, 10, 33);
Year, Month, Day, Hours, Minutes, Seconds: Creates a date object with specified year, month, day, hours, minutes and seconds. const fullDate = new Date(2022, 11, 24, 10, 33);
Date () constructor - JavaScript | MDN
17 Noll 1995 · The Date () constructor creates Date objects. When called as a function, it returns a string representing the current time.
JavaScript Dates - W3Schools
2 days ago · When a date object is created, a number of methods allow you to operate on it. Date methods allow you to get and set the year, month, day, hour, minute, second, and millisecond of …
Date and time - The Modern JavaScript Tutorial
14 DFómh 2022 · We can always create a date from a timestamp using new Date(timestamp) and convert the existing Date object to a timestamp using the date.getTime() method (see below).
JavaScript Date () Constructor - GeeksforGeeks
23 Iúil 2025 · JavaScript Date constructor is used to create a new Date object. The value returned will be different on the basis of whether the object is called with or without the new keyword.
Javascript create Date from year, month, day integer values
I am trying to create a new Date instance in Javascript. I have integer values representing year, month and day. Following this tutorial, syntax for creating a new Date should be: and that is …
JavaScript Date: Create, Convert, Compare Dates in JavaScript
5 Feabh 2019 · Use the Date () function to get the string representation of the current date and time in JavaScript. Use the new keyword in JavaScript to get the Date object. Create a date …
JavaScript Tutorial => Create a new Date object
To create a new Date object use the Date() constructor: Date() creates a Date instance containing the current time (up to milliseconds) and date. Date(m) creates a Date instance containing the …
Understanding JavaScript Date and New Date Functions
The new Date () constructor in JavaScript allows you to create a new Date object representing the current date and time. You can also pass specific parameters to create a Date object for a …
JavaScript new Date Method - W3Schools
Example Create a new date object with the current date and time: // Create a Date const time = new Date (); Try it Yourself »
Handling Dates and Times with JavaScript’s Date Object
9 Aib 2025 · There are several ways to instantiate a Date object. Calling new Date () with no arguments creates a new Date object representing the current date and time according to the …
- Iarrann daoine freisin