Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Javascript setDate() Method

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 146
    Comment on it

    In Javascript setDate ( ) method set the day of the Date object based on the beginning of the current month( or local time) .
    Syntax

    dateObj.setDate ( dayValue ) 
    

    Parameters dateObj -> It is mandatory and it is an integer which represent the day of the month .
    dayValue -> It is also required and accept only a numeric value and this value is equal to the day of the month .
    Return
    This method will return the number of milliseconds since 1 January 1970 .

    Suppose the value of dayValue is greater than number of days in the month than the date will jump to the next month/year . For example date is 17 september and you invoke setDate(32) than the date change to 1st october .And if the value of dayValue is in negative than date will jump to previous month/year . For example date is 17 september and you invoke setDate( -32 ) than the date change to 1st August . And if the dayValue is equal to 0 then date will be set to the last day of the previous month .

    Example ->

    var date = new Date ( " 09/17/1992 " ) ;
    date.setDate ( 30 ) ;
    document.write ( date ) ; // Output Thursday September 1992
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: