Go Back

Date time Method in JavaScript

Fri Aug 20 2021 20:15:30 GMT+0000 (Coordinated Universal Time)
All Articles

#date, #javascript date #date in javascript, #javascript date object, #date methods,

Date time Method in JavaScript

 

JavaScript provides Date Method   to work with date & time, including days, months, years, hours, minutes, seconds, and milliseconds:

  1. getDate( ) Returns day of the month.
  2. getDay( ) Returns day of the week from 0 to 6.
  3. getFullYear( ) Returns year with 4 digits.
  4. getMonth( ) Returns month from 0 to 11.
  5. getHours( ) Returns the hour (0 to 23).
  6. getMinutes( ) Returns the minute component.
  7. getSeconds( ) Returns the seconds component.
  8. toString( ) Returns the string representation of Date object
    var d=new Date();
    var str=d.toString();
    The result of str will be:
    Mon Feb 04 2013 12:30:59 GMT+0530 (India Standard Time)
  9.  toDateString( ) Returns the string representation of date portion of Date object.
    var d=new Date();
    var str=d.toDateString();
    The result of str will be:
    Mon Feb 04 2013
  10. toTimeString( ) Returns the string representation of time  portion of Date object
    var d=new Date();
    var str=d.toTimeString();
    The result of str will be:
    12:33:39 GMT+0530 (India Standard Time)
showing an illustration of  Date time Method in JavaScript  and <p>#date, #javascript date #date in javascript, #javascript date object, #date methods,</p>

Article