Time to get the JavaScript date object

Source: Internet
Author: User
Tags local time

JavaScript Date Object-Get time:

Test code:

<!    DOCTYPE html>Body {background-color: #333; color:white;} </style>/** * * 1. Get time*/        varD =NewDate ();//Date () returns the day and time.         varD_date = D.getdate ();//getDate () returns the day of the one month (1 ~ 31) from the Date object.         varD_day = D.getday ();//GetDay () returns the day of the week (0 ~ 6) from the Date object.         varD_moth = D.getmonth ();//GetMonth () returns the month (0 ~ 11) from the Date object.         varD_fullyear = D.getfullyear ();//getFullYear () returns the year as a four-digit number from a Date object.         varD_year = D.getyear ();//please use the getFullYear () method instead.         varD_hour = D.gethours ();//getHours () returns the hour (0 ~ 23) of the Date object.         varD_minute = D.getminutes ();//getminutes () returns the minute (0 ~ 59) of the Date object.         varD_second = D.getseconds ();//getseconds () returns the number of seconds (0 ~ 59) of the Date object.         varD_milliseconds = D.getmilliseconds ();//getmilliseconds () returns the milliseconds (0 ~ 999) of the Date object.         varD_time = D.gettime ();//GetTime () returns the number of milliseconds since January 1, 1970.         varD_timezoneoffset = D.gettimezoneoffset ();//getTimezoneOffset () returns the minute difference between local time and Greenwich Mean Time (GMT).         varD_utcdate = D.getutcdate ();//getUTCDate () returns the day of the month (1 ~ 31) from the Date object according to the world.         varD_utcday = D.getutcday ();//GetUTCDay () returns the day of the week (0 ~ 6) from the Date object according to the world.         varD_utcmonth = D.getutcmonth ();//getUTCMonth () returns the month (0 ~ 11) from the Date object, depending on the world.         varD_utcfullyear = D.getutcfullyear ();//getUTCFullYear () returns a four-digit year from a Date object according to the world.         varD_utchour = D.getutchours ();//getutchours () returns the hour (0 ~ 23) of the Date object according to the universal.         varD_utcminute = D.getutcminutes ();//getUTCMinutes () the minute (0 ~ #) of the date object returned according to the GMT        varD_utcseconds = D.getutcseconds ();//getUTCSeconds () returns the second (0 ~ 59) of the Date object according to the universal.         varD_utcmillisecond = D.getutcmilliseconds ();//getUTCMilliseconds () returns the milliseconds (0 ~ 999) of a Date object based on the universal.         varParsemmlliseconds = Date.parse ("Jul 8, 2005");//Parse () returns the number of milliseconds from midnight January 1, 1970 to the specified date (string). (Call Method: Date.parse (datestring))        varUTCMILLISECONDS1 = DATE.UTC (2005,7,8);//UTC () returns the number of milliseconds from January 1, 1970 to the specified date, depending on the time. "Syntax: DATE.UTC (year,month,day,hours (*), minutes (*), seconds (*), MS (*))" NOTE: (*) indicates optional        varUtcmilliseconds2=NewDate (DATE.UTC (2005,7,8));//UTC () returns the number of milliseconds from January 1, 1970 to the specified date, depending on the time. "Syntax: DATE.UTC (year,month,day,hours (*), minutes (*), seconds (*), MS (*))" NOTE: (*) indicates optional        vard_valueof = D.valueof ();//valueOf () returns the original value of the Date object. The millisecond representation of the date. The return value and method Date.gettime return the same value. document.write (' d==== ' +d+ ' <br><br> ' ); document.write (' ddate==== ' +d_date+ ' <br><br> '); document.write (' dday==== ' +d_day+ ' <br><br> '); document.write (' dmoth==== ' +d_moth+ ' <br><br> '); document.write (' dfullyear==== ' +d_fullyear+ ' <br><br> '); document.write (' dyear==== ' +d_year+ ' <br><br> '); document.write (' dhour==== ' +d_hour+ ' <br><br> '); document.write (' dminute==== ' +d_minute+ ' <br><br> '); document.write (' dsecond==== ' +d_second+ ' <br><br> '); document.write (' dmilliseconds==== ' +d_milliseconds+ ' <br><br> '); document.write (' dtime==== ' +d_time+ ' <br><br> '); document.write (' dtimezoneoffset==== ' +d_timezoneoffset+ ' <br><br> '); document.write (' dutcdate==== ' +d_utcdate+ ' <br><br> '); document.write (' dutcday==== ' +d_utcday+ ' <br><br> '); document.write (' dutcmonth==== ' +d_utcmonth+ ' <br><br> '); document.write (' dutcfullyear==== ' +d_utcfullyear+ ' <br><br> '); document.write (' dutchour==== ' +d_utchour+ ' <br><br> '); document.write (' dutcminute==== ' +d_utcminute+ ' <br><br> '); document.write (' dutcseconds==== ' +d_utcseconds+ ' <br><br> '); document.write (' dutcmillisecond==== ' +d_utcmillisecond+ ' <br><br> '); document.write (' parsemmlliseconds==== ' +parsemmlliseconds+ ' <br><br> '); document.write ("utcmilliseconds1====" +utcmilliseconds1+ ' <br><br> '); document.write ("utcmilliseconds2====" +utcmilliseconds2+ ' <br><br> '); document.write ("dateobj_valueof====" +d_valueof+ ' <br><br> '); </script></body>

Test results:

Time to get the JavaScript date object

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.