JavaScript Date Object
Date object allows us to work with all variables related to the calendar and time management (duration time). The syntax to create objects date is the following:
Date object allows us to work with all variables related to the calendar and time management (duration time). The syntax to create objects date is the following:
Obyek_Name = new Date ()
This syntax allows us to store the date and time.
Obyek_Name = new Date ("day, month date year hour: minutes: seconds")
Make parameter string with the boundary line dividing a case of the above formats.
Obyek_Name = new Date (year, month, day)
Is three integer parameters separated by commas
Obyek_Name = new Date (year, month, day, hour, minute, seconds [,millisecond])
Is six integer parameters separated by commas
JavaScript stores dates in the form of a string containing the day, month, year, hours, minutes and seconds. Despite this very difficult for us to be able to access an element of time above by using a string object, because each element has a different size. Conversely date object allows us to access and modify an element.
Here is a table of a few standard methods of date object :
getdate () to obtain the number corresponding to the number of days in a month. The result is an integer with a value between 1 to 31, corresponding to number of days in a month
getDay () to obtain the number corresponding to the number of days in a week. The results are integers related to the number days of the week
• 0: Sunday
• 1: Monday
• ...
getFullYear () to obtain the number corresponding to the year in 4 digit. The results are integer numbers related to the year in question with the format XXXX
getHours () to obtain the number corresponding to the unit. The result is an integer with a value between 0 to 23 which corresponds to the object date
getMilliseconds () to obtain numbers corresponding to the object. The result is an integer between 0 and 999 milliseconds units corresponding to millisecond of the object passed in parameter.
getMinutes () to obtain the number corresponding to the unit of minute objects. The result is an integer between 0 and 59 corresponding to the minutes from the object passed in parameter
getMonth () to obtain numbers corresponding to the number months of the year. The results are integers related to the number months of the year
• 0: January
• 1: February
• ... ..
getSeconds () to obtain numbers that correspond with units of seconds. The result is an integer between 0 and 59 corresponding to the second of the object that is passed in parameter
getTime () to obtain the number of seconds since 1 January 1970. The result is integer, this method is very useful to spend one date to another date, or also adding two dates, etc
getTimeZoneOffset () to obtain the time difference between local time and GMT. The result is an integer corresponding to how many minutes difference from GMT
getYear () to obtain the value in 2 years the number of objects that date. The results are integers corresponding by year XX
toGMTString () to convert a date into a string with the format GMT. The result is a string of the format Wed, 3 Dec 2003: 15:15:20 GMT
toLocalString () to convert a date into a string with the format of the local result is a string with the format depends on the local system as an example: 3/12/03 15:15:20
setDate (X) to give the numbers corresponding to the number of days in a month parameter is an integer between 1 and 31 which corresponds with the number of days in a month
setDay (X) to give a figure corresponding to the number of days in a week parameter is an integer corresponding to the number days of the week:
• 0: Sunday
• 1: Monday
• ...
setHours (X) to provide value at the parameter is an integer between 0 to 23 corresponding to the number of hours
setMonth (X) to give the numbers corresponding to the number in the parameter is an integer between 0 and 11 months corresponding to the number
• 0: January
• 1: February
• ....
setTime (X) to determine the date parameter is the integer corresponding to the number of seconds since 1 January 1970
0 comments:
Post a Comment