Hirdetés

Aktív témák

  • Fisha

    őstag

    válasz laxius_ #1 üzenetére

    var d = new Date();

    Thus, variable d contains a new date object. We can now call the various methods of this date object.

    var t_date = d.getDate(); // Returns the day of the month
    var t_mon = d.getMonth(); // Returns the month as a digit
    var t_year = d.getFullYear(); // Returns 4 digit year
    var t_hour = d.getHours(); // Returns hours
    var t_min = d.getMinutes(); // Returns minutes
    var t_sec = d.getSeconds(); // Returns seocnds
    var t_mil = d.getMilliseconds; // Returns Milliseconds


    Now we can easily display the date, month and year in an alert box, using the values stored in respective variables.

    alert(''Today's date is '' + t_date + ''-'' + t_mon + ''-'' + t_year);

Aktív témák