Oscail naisc i dtáb nua
    • Tuairisc Oibre
    • Ríomhphost
    • Athscríobh
    • Caint
    • Gineadóir Teidil
    • Freagra Cliste
    • Dán
    • Aiste
    • Scéal grinn
    • Postáil Instagram
    • Postáil X
    • Postáil Facebook
    • Scéal
    • Litir chlúdaigh
    • Atosaigh
    • Tuairisc den Jab
    • Litir Mholta
    • Litir éirí as
    • Litir Chuireadh
    • Greeting Message
    • Bain triail as tuilleadh teimpléad
  1. 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 time
    const now = new Date();
    console.log(now); // Outputs current date and time

    // Specific date and time
    const 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, milliseconds
    const detailedDate = new Date(2022, 11, 24, 10, 33, 30, 0);
    console.log(detailedDate); // Outputs: Sat Dec 24 2022 10:33:30 GMT
    Cóipeáilte!

    Using Different Constructors

    1. No Parameters: Creates a date object with the current date and time. const currentDate = new Date();

    2. Date String: Creates a date object from a date string. const dateString = new Date("October 13, 2014 11:13:00");

    3. 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)

    4. Year, Month, Day: Creates a date object with specified year, month, and day. const yearMonthDay = new Date(2022, 11, 24);

    5. Year, Month, Day, Hours: Creates a date object with specified year, month, day, and hours. const yearMonthDayHour = new Date(2022, 11, 24, 10);

    6. 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);

    7. 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);

    Aiseolas
    Go raibh maith agat!Inis tuilleadh dúinn
  2. 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.

  3. 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 …

  4. 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).

  5. 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.

  6. 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 …

  7. 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 …

  8. 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 …

  9. 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 …

  10. 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 »

  11. 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 …

  12. Iarrann daoine freisin