The month before the next day of the day before the javaScript day, the month before

Source: Internet
Author: User
Tags time zones

The month before the next day of the day before the javaScript day, the month before


// Monthly subscription on the date of the previous month
// Previous month
Function LEFT_CALENDAR (){


Var output = new Date (disp. get ("CALENDAR"). replace (/-/g ,"/"));
Output. setTime (output. getTime ());

Var output1 = new Date (disp. get ("CALENDAR"). replace (/-/g ,"/"));
Output1.setTime (output1.getTime ());

Var output2 = new Date (disp. get ("CALENDAR"). replace (/-/g ,"/"));
Output2.setTime (output2.getTime ());
Output2.setDate (1 );
Output2.setDate (0 );

If (output1.getDate ()> output2.getDate ()){
Output. setDate (1 );
Output. setMonth (output. getMonth ()-1 );
Output. setDate (output2.getDate ());
} Else {
Output. setMonth (output. getMonth ()-1 );
}

Var year = output. getFullYear ();
Var month = output. getMonth () + 1;
Var day = output. getDate ();
Var outputF = year + "-" + month + "-" + day;
Disp. set ("CALENDAR", outputF );
Document. getElementById ("sidCALENDAR"). focus ();
Return true;
}
// Monthly renewal
Function RIGHT_CALENDAR (){
Var output = new Date (disp. get ("CALENDAR"). replace (/-/g ,"/"));
Output. setTime (output. getTime ());

Var output1 = new Date (disp. get ("CALENDAR"). replace (/-/g ,"/"));
Output1.setTime (output1.getTime ());

Var output2 = new Date (disp. get ("CALENDAR"). replace (/-/g ,"/"));
Output2.setTime (output2.getTime ());
Output2.setDate (1 );
Output2.setMonth (output2.getMonth () + 2 );
Output2.setDate (0 );

If (output1.getDate ()> output2.getDate ()){
Output. setDate (1 );
Output. setMonth (output. getMonth () + 1 );
Output. setDate (output2.getDate ());
} Else {
Output. setMonth (output. getMonth () + 1 );
Output. setDate (output. getDate ());
}

Var year = output. getFullYear ();
Var month = output. getMonth () + 1;
Var day = output. getDate ();
Var outputF = year + "-" + month + "-" + day;
Disp. set ("CALENDAR", outputF );
Document. getElementById ("sidCALENDAR"). focus ();
Return true;
}




// Previous day
Function LEFT_CALENDAR (){

Var output = new Date (disp. get ("CALENDAR"). replace (/-/g ,"/"));
Output. setTime (output. getTime ()-7x24x60*60*1000 );
Var year = output. getFullYear ();
Var month = output. getMonth () + 1;
Var day = output. getDate ();
Var outputF = year + "-" + month + "-" + day;
Disp. set ("CALENDAR", outputF );
Document. getElementById ("sidCALENDAR"). focus ();
Return true;
}


// The following day
Function RIGHT_CALENDAR (){
Var output = new Date (disp. get ("CALENDAR"). replace (/-/g ,"/"));
Output. setTime (output. getTime () + 7*24*3600*1000 );
Var year = output. getFullYear ();
Var month = output. getMonth () + 1;
Var day = output. getDate ();
Var outputF = year + "-" + month + "-" + day;
Disp. set ("CALENDAR", outputF );
Document. getElementById ("sidCALENDAR"). focus ();

Return true;

}


Time Functions under js
Date (object)
The Date object allows you to obtain the Time and Date relative to the International Standard Time (Greenwich Mean Time, now known as UTC-Universal Coordinated Time) or the operating system running on the Flash Player. To use the Date object method, you must first create a Date object entity (Instance ).

The Date object must use a player of Flash 5 or a later version.

The Date object method is not static, but can be applied to specified individual objects during use.

Date object Method Introduction:

· GetDate | get the current date based on the local time (number of the current month)
· GetDay | obtains the day of the week (0-Sunday, 1-Monday...) based on the local time ...)
· GetFullYear | obtains the current year based on the local time (four digits)
· GetHours | obtains the current hour (in the 24-hour format, ranging from 0 to 23) based on the local time)
· GetMilliseconds | obtains the current number of milliseconds based on the local time
· GetMinutes | obtains the current number of minutes based on the local time
· GetMonth | obtains the current month based on the local time (Note: Starting from 0: 0-Jan, 1-Feb ...)
· GetSeconds | obtains the current number of seconds based on the local time
· GetTime | obtains the number of milliseconds since, January 1, in UTC format.
· GetTimezoneOffset | obtains the offset value of the current time and UTC format (in minutes)
· GetUTCDate | get the current date in UTC format (number of the current month)
· GetUTCDay | obtains the day of the week in UTC format (0-Sunday, 1-Monday ...)
· GetUTCFullYear | obtains the current year (four digits) in UTC format)
· GetUTCHours | get the current hour in UTC format (24-hour, 0-23)
· GetUTCMilliseconds | obtains the current millisecond count in UTC format.
· GetUTCMinutes | get the current number of minutes in UTC format
· GetUTCMonth | get the current month in UTC format (Note: Starting from 0: 0-Jan, 1-Feb ...)
· GetUTCSeconds | obtains the current number of seconds in UTC format.
· GetYear | obtains the current abbreviated year (current year minus 1900) based on the local time)
· SetDate | set the current date (number of the current month)
· SetFullYear | set the current year (four digits)
· SetHours | set the current hour (24-hour, 0-23)
· SetMilliseconds | set the current number of milliseconds
· SetMinutes | set the current number of minutes
· SetMonth | set the current month (Note: 0-Jan, 1-Feb ...)
· SetSeconds | set the current number of seconds
· SetTime | set the number of milliseconds since in UTC format
· SetUTCDate | set the current date in UTC format (number of the current month)
· SetUTCFullYear | current year in UTC format (four digits)
· SetUTCHours | set the current hour in UTC format (24-hour, 0-23)
· SetUTCMilliseconds | set the current number of milliseconds in UTC format
· SetUTCMinutes | set the current number of minutes in UTC format
· SetUTCMonth | set the current month in UTC format (Note: Starting from 0: 0-Jan, 1-Feb ...)
· SetUTCSeconds | set the current number of seconds in UTC format
· SetYear | set the current abbreviation year (current year minus 1900)
· ToString | converts a datetime value to a string value in the form of "date/time ".
· Date. UTC | returns the fixed time value of the specified UTC format Date and time.

Create a new Date object

Syntax:
New Date ();
New Date (year [, month [, date [, hour [, minute [, second [, millisecond]);
Parameters:
Year is an integer between 0 and 99, corresponding to 1900 to 1999, or a specified year for four digits;
Month is an integer between 0 (January) and 11 (December). This parameter is optional;
Date is an integer between 1 and 31. this parameter is optional;
Hour is an integer between 0 (am) and 23 (pm). This parameter is optional;
Minute is an integer between 0 and 59. this parameter is optional;
Second is an integer between 0 and 59. this parameter is optional;
Millisecond is an integer ranging from 0 to 999. this parameter is optional;
Note:
Object. Create a Date object.
Player support:
Flash 5 or later versions.
Example:
The following is an example of obtaining the current date and time:
Now = new Date ();
The following example creates a Date object for the National Day:
National_day = new Date (49, 10, 1 );
The following example shows how to use the getMonth, getDate, and getFullYear methods of the Date object to obtain the time after creating a Date object, and then output it in the dynamic text box.
MyDate = new Date ();
DateTextField = (mydate. getMonth () + "/" + myDate. getDate () + "/" + mydate. getFullYear ());


Date> Date. getDate
Date. getDate

Syntax: myDate. getDate ();
Parameter: None
Note:
Method. Obtain the current date (number of the current month) based on the local time. The returned value is an integer between 1 and 31.
Player support: Flash 5 or later.

Date> Date. getDay
Date. getDay

Syntax: myDate. getDay ();
Parameter: None
Note:
Method. Obtain the day of the week (0-Sunday, 1-Monday...) based on the local time ...). The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.

Date> Date. getFullYear
Date. getFullYear

Syntax: myDate. getFullYear ();
Parameter: None
Note:
Method. Obtain the current year based on the local time (four digits, such as 2000 ). The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.
Example:
In the following example, a Date object is created, and the year obtained using the getFullYear method is output in the output window:
MyDate = new Date ();
Trace (myDate. getFullYear ());

Date> Date. getHours
Date. getHours

Syntax: myDate. getHours ();
Parameter: None
Note:
Method. Obtain the current hour based on the local time (in 24-hour format, the returned value is an integer between 0 and 23 ). The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.

Date> Date. getMilliseconds
Date. getMilliseconds

Syntax: myDate. getMilliseconds ();
Parameter: None
Note:
Method. Obtain the current number of milliseconds based on the local time (the returned value is an integer between 0 and 999 ). The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.

Date> Date. getMinutes
Date. getMinutes

Syntax: myDate. getMinutes ();
Parameter: None
Note:
Method. Obtain the current number of minutes based on the local time (the returned value is an integer between 0 and 59 ). The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.

Date> Date. getMonth
Date. getMonth

Syntax: myDate. getMonth ();
Parameter: None
Note:
Method. Obtain the current month based on the local time (Note: from 0 to January, 1 to February ...). The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.

Date> Date. getSeconds
Date. getSeconds

Syntax: myDate. getSeconds ();
Parameter: None
Note:
Method. Obtain the current number of seconds based on the local time (the returned value is an integer between 0 and 59 ). The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.

Date> Date. getTime
Date. getTime

Syntax: myDate. getTime ();
Parameter: None
Note:
Method. Returns the number of milliseconds that have elapsed since am, January 1, January 1, 1970, in UTC format. This method can be used to describe the same instantaneous time in different time zones.
Player support: Flash 5 or later.

Date> Date. getTimezoneOffset
Date. getTimezoneOffset

Syntax: mydate. getTimezoneOffset ();
Parameter: None
Note:
Method. Obtains the offset value of the current time and UTC format (in minutes ).
Player support: Flash 5 or later.
Example:
The following example returns the offset between Beijing time and UTC time.
New Date (). getTimezoneOffset ();
The result is as follows:
480 (8 hours * 60 minutes/hour = 480 minutes)

Date> Date. getUTCDate
Date. getUTCDate

Syntax: myDate. getUTCDate ();
Parameter: None
Note:
Method. Obtain the current date in UTC format (number of the current month ).
Player support: Flash 5 or later.

Date> Date. getUTCDay
Date. getUTCDay

Syntax: myDate. getUTCDate ();
Parameter: None
Note:
Method. Obtain the day of the week in UTC format (0-Sunday, 1-Monday ...).
Player support: Flash 5 or later.

Date> Date. getUTCFullYear
Date. getUTCFullYear

Syntax: myDate. getUTCFullYear ();
Parameter: None
Note:
Method. Obtains the current year (four digits) in UTC format ).
Player support: Flash 5 or later.

Date> Date. getUTCHours
Date. getUTCHours

Syntax: myDate. getUTCHours ();
Parameter: None
Note:
Method. Obtain the current hour in UTC format (in 24-hour format, the return value is an integer between 0 and 23 ).
Player support: Flash 5 or later.

Date> Date. getUTCMilliseconds
Date. getUTCMilliseconds

Syntax: myDate. getUTCMilliseconds ();
Parameter: None
Note:
Method. Obtain the current number of milliseconds in UTC format (the returned value is an integer between 0 and 999 ).
Player support: Flash 5 or later.

Date> Date. getUTCMinutes
Date. getUTCMinutes

Syntax: myDate. getUTCMinutes ();
Parameter: None
Note:
Method. Obtain the current number of minutes in UTC format (the returned value is an integer between 0 and 59 ).
Player support: Flash 5 or later.

Date> Date. getUTCMonth
Date. getUTCMonth

Syntax: myDate. getUTCMonth ();
Parameter: None
Note:
Method. Obtain the current month in UTC format (Note: from 0 to January, 1 to February ...).
Player support: Flash 5 or later.

Date> Date. getUTCSeconds
Date. getUTCSeconds

Syntax: myDate. getUTCSeconds ();
Parameter: None
Note:
Method. Returns the current number of seconds in UTC format. The returned value is an integer between 0 and 59 ).
Player support: Flash 5 or later.

Date> Date. getYear
Date. getYear

Syntax: myDate. getYear ();
Parameter: None
Note:
Method. Obtain the current abbreviated year (current year minus 1900) based on the local time ). The local time is determined by the operating system of the Flash Player. For example, 100 is used for representation.
Player support: Flash 5 or later.

Date> Date. setDate
Date. setDate

Syntax: myDate. setDate (date );
Parameter: date is an integer between 1 and 31.
Note:
Method. Set the current date (number of the current month) based on the local time ). The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.

Date> Date. setFullYear
Date. setFullYear

Syntax: myDate. setFullYear (year [, month [, date]);
Parameters:
The four-digit integer specified by year indicates the specified year. The two digits do not represent the year. For example, 99 does not represent 1999, and only indicates year 99.
Month is an integer between 0 (January) and 11 (December). This parameter is optional.
Date is an integer from 1 to 31. this parameter is optional.
Note:
Method. Set the year based on the local time. If the month and date parameters are set, both the month and the date are set. The local time is determined by the operating system of the Flash Player. The value obtained by the getUTCDay and getDay Methods changes accordingly.
Player support: Flash 5 or later.

Date> Date. setHours
Date. setHours

Syntax: myDate. setHours (hour );
Parameter: hour is an integer from 0 (am) to 23 (pm.
Note:
Method. Set the current hour based on the local time. The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.

Date> Date. setMilliseconds
Date. setMilliseconds

Syntax: myDate. setMilliseconds (millisecond );
Parameter: millisecond is an integer from 0 to 999.
Note:
Method. Set the current number of milliseconds according to the local time. The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.


Date> Date. setMinutes
Date. setMinutes

Syntax: myDate. setMinutes (minute );
Parameter: minute is an integer from 0 to 59.
Note:
Method. Set the current number of minutes according to the local time. The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.

Date> Date. setMonth
Date. setMonth

Syntax: myDate. setMonth (month [, date]);
Parameters:
Month is an integer between 0 (January) and 11 (December ).
Date is an integer from 1 to 31. this parameter is optional.
Note:
Method. Set the current month number based on the local time. If the date parameter is selected, the date is set at the same time. The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.

Date> Date. setSeconds
Date. setSeconds

Syntax: myDate. setSeconds (second );
Parameter: second is an integer from 0 to 59.
Note:
Method. Set the current number of seconds according to the local time. The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.

Date> Date. setTime
Date. setTime

Syntax: myDate. setTime (millisecond );
Parameter: millisecond is an integer from 0 to 999.
Note:
Method. Set the specified date in milliseconds.
Player support: Flash 5 or later.

Date> Date. setUTCDate
Date. setUTCDate

Syntax: myDate. setUTCDate (date );
Parameter: date is an integer from 1 to 31.
Note:
Method. The Date is set in UTC format. Using this method will not affect the values of other fields of the Date object, but the getUTCDay and getDay methods will return the corresponding new values after the Date is changed.
Player support: Flash 5 or later.

Date> Date. setUTCFullYear
Date. setUTCFullYear

Syntax: myDate. setUTCFullYear (year [, month [, date]);
Parameters:
Year represents the four-digit integer of the year, for example, 2000
Month is an integer ranging from 0 (January) to 11 (December). An optional parameter.
Date is an integer from 1 to 31. An optional parameter.
Note:
Method. The year is set in UTC format. If an optional parameter is used, the month and date are also set. The getUTCDay and getDay Methods return a new value.
Player support: Flash 5 or later.

Date> Date. setUTCHours
Date. setUTCHours

Syntax: myDate. setUTCHours (hour [, minute [, second [, millisecond]);
Parameters:
Hour is an integer from 0 (am) to 23 (pm.
Minute is an integer from 0 to 59. An optional parameter.
Second is an integer from 0 to 59. An optional parameter.
Millisecond is an integer from 0 to 999. An optional parameter.
Note:
Method. Set the hours in UTC format. If an optional parameter is used, the values of minutes, seconds, and milliseconds are also set.
Player support: Flash 5 or later.

Date> Date. setUTCMilliseconds
Date. setUTCMilliseconds

Syntax: myDate. setUTCMilliseconds (millisecond );
Parameter: millisecond is an integer from 0 to 999.
Note:
Method. Sets the number of milliseconds in UTC format.
Player support: Flash 5 or later.

Date> Date. setUTCMinutes
Date. setUTCMinutes

Syntax: myDate. setUTCMinutes (minute [, second [, millisecond]);
Parameters:
Minute is an integer from 0 to 59. An optional parameter.
Second is an integer from 0 to 59. An optional parameter.
Millisecond is an integer from 0 to 999. An optional parameter.
Note:
Method. Set the number of minutes in UTC format. If an optional parameter is used, the second and millisecond values are also set.
Player support: Flash 5 or later.

Date> Date. setUTCMonth
Date. setUTCMonth

Syntax: myDate. setUTCMonth (month [, date]);
Parameters:
Month is an integer between 0 (January) and 11 (December ).
Date is an integer from 1 to 31. this parameter is optional.
Note:
Method. Set the month in UTC format and optional date. The getUTCDay and getDay Methods return the corresponding new values.
Player support: Flash 5 or later.

Date> Date. setUTCSeconds
Date. setUTCSeconds

Syntax: myDate. setUTCSeconds (second [, millisecond]);
Parameters:
Second is an integer from 0 to 59. An optional parameter.
Millisecond is an integer from 0 to 999. An optional parameter.
Note:
Method. Sets the number of seconds in UTC format. If an optional parameter is used, the millisecond value is also set.
Player support: Flash 5 or later.

Date> Date. setYear
Date. setYear

Syntax: myDate. setYear (year );
Parameter: year is a four-digit integer representing the year, for example, 2000.
Note:
Method. Set the year based on the local time. The local time is determined by the operating system of the Flash Player.
Player support: Flash 5 or later.

Date> Date. toString
Date. toString

Syntax: myDate. toString ();
Parameter: None
Note:
Method. Converts a datetime value to a string value in the form of "date/time ".
Player support: Flash 5 or later.
Example:
The following example outputs the national_day object of the National Day as a readable string:
Var national_day = newDate (49, 9, 1, 10, 00 );
Trace (national_day.toString ());
Output (for Pacific Standard Time ):
Result: Sat Oct 1 10:00:00 GMT + 0800 1949

Date> Date. UTC
Date. UTC

Syntax: Date. UTC (year, month [, date [, hour [, minute [, second [, millisecond]);
Parameters:
Year represents the four-digit integer of the year, for example, 2000
Month is an integer between 0 (January) and 11 (December.
Date is an integer from 1 to 31. An optional parameter.
Hour is an integer from 0 (am) to 23 (pm.
Minute is an integer from 0 to 59. An optional parameter.
Second is an integer from 0 to 59. An optional parameter.
Millisecond is an integer from 0 to 999. An optional parameter.
Note:
Method. Returns the number of milliseconds from am, January 1, January 1, 1970. This is a static method that does not require specific objects. It can create a new Date object in UTC format, while new Date () creates a Date object in local time.
Player support: Flash 5 or later.




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.