Use of date

Source: Internet
Author: User

Method

Description

Date ()

Returns the date and time of the current day.

Getdate ()

Get the current day (1-31)

Getday ()

Obtain the day of the week (0-6)

Getmonth ()

Get month (0-11)

Getfullyear ()

Obtain the complete year

Getyear ()

Get year

Gethours ()

Obtain the hour (0-23)

Getminutes ()

Get minutes (0-59)

Getseconds ()

Obtain seconds (0-59)

Getmilliseconds ()

Obtain Millisecond (0-999)

Gettime ()

Get the number of milliseconds from 1970.1.1 to the present

Parse ()

Obtains the number of milliseconds from midnight to the specified date in 1970.1.1.

Setdate ()

Set days

Setmonth ()

Set month

Setfullyear ()

Set the complete year

Setyear ()

Set year

Sethours ()

Set hours

Setminutes ()

Set score

Setseconds ()

Set seconds

Setmilliseconds ()

Set millisecond

Settime ()

Calculated by adding or subtracting the specified number of milliseconds from the midnight value in 1970.1.1

Tostring ()

Converts a date () object to a string.

 


<SCRIPT type = "text/JavaScript" Language = "JavaScript">

// Use the specified year, month, or day to create a date object
// Var date = new date (1988,10, 11 );
// Document. Write (date. getyear (); // output 88 (cause: Get the difference between the year and the month)
// Document. Write (date. getfullyear (); // output 1988

VaR date = new date (); // create the current date object
VaR year = date. getfullyear ();
VaR month = date. getmonth ();
VaR day = date. getdate ();
VaR hour = date. gethours ();
Hour = hour <10? "0" + hour: hour;
VaR minute = date. getminutes ();
Minute = minute <10? "0" + minute: minute;

VaR second = date. getseconds ();
Second = Second <10? "0" + Second: second;
Document. Write (Year + "-" + (month + 1) + "-" + day + "" + hour + ":" + minute + ":" + second );
If (hour <13 ){
Document. Write ("<br> am ");
} Else {
Document. Write ("<br> PM ");
}
Document. Write ("<br> Week" + date. getday ());
</SCRIPT>

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.