Date is a very useful object that returns the date and time of the system in the following format: Weekday, month name, Month Day, Hour:Minute:Second and Year. As any object, you can create new instances and this practice enables the use of how many date objects are required.

The instance of the object is given as follows:

NewObject = NEW date ()

  • NewObject = Object defined by user to handle dates

The Date object has a number of methods that aim to assist in identifying important temporal elements.

 

getMonth – Gets the number of the month, returning a value between 0 and 11 (January = 0)

Eg: Month = NewObject.getMonth ()

 

setMonth – Sets a new value for the month. The value must be between 0..11

Eg.: NewObject.setMonth (NumeroDoMes)

 

getDate – Gets the number of the day, considering the month, returning a numeric value between 1..31.

Eg.: day = NewObject.getDate ()

 

setDate – Sets a new value for the date. This value should be between 1..31

Eg.: NewObject.setDate (NumeroDoDia)

 

getDay – Gets the number of the day, considering the week, returning a numeric value between 0..6. Remember that the week starts on Sunday, so 0 is Sunday

Eg.: DayOfWeek = NewObject.getDay ()

 

getHours – Gets a number corresponding to time, returning a numeric value between 0..23

Eg.: Time = NewObject.getHours ()

 

setHours – Sets a new value for the hour. The value must be between 0..23

Eg.: NewObject.setHours (datetime)

 

getMinutes – Gets a number corresponding minutes, returning a numeric value between 0..59

Eg.: Minutes = NewObject.getMinutes ()

 

setMinutes – Sets a new value for minutes. The value must be between 0..59

Eg.: NewObject.setMinutes (Minutes)

 

getSeconds – Gets a number corresponding to the second, returning a numeric value between 0..59

Eg.: Seconds = NewObject.getSeconds ()

 

setSeconds – Sets a new value for the seconds. The value must be between 0..59

Eg.: NewObject.setSeconds (seconds)

 

getTime – Gets the time from 01/01/70 to date. The only drawback is that this date is given in milliseconds.

Eg.: ElapsedTime = NewObject.getTime ()

 

setTime – Establishes a new date.

Eg: BirthDate = new Date (“August 2, 1970”)

 

getTimezoneOffset – Gets the difference between local time and the time of the central meridian (Greenwich). This time is given in minutes, just to find out the time zone, you must divide the result obtained by this function for 60.

Eg.: Timezone NewObject.getTimezoneOffset = () / 60

 

getYear – Gets a numerical value corresponding to the year.

Eg.: Year = NewObject.getYear ()

 

setYear – Establishes a new value annually. The value should be greater than or equal to 1900.

Eg.: NewObject.setYear (1997)

 

toGMTString – Converts a date object to a string following the pattern Internet GMT.

Eg.: NewObject.toGMTstring ()

 

toLocaleString – Converts a date to a string following the local standard.

Eg.: NewObject.toLocalString ()

Visit our blog and check out more content!

By ,

February 25, 2016

a

You might also like…

“We developed RISK4ALL, a SaaS platform that allows implementing GRC in an organization with total security and privacy.” (RISK4ALL)

Come and discover the success case of the Risk4all, software, a multilingual and multi-company SaaS...

Security in web applications

In this article, you will learn about web application security and the options within Scriptcase th...

“We have developed the Connected Citizen Card, which assists public administrators in decision-making and policy creation.”(Assist Soluções em TI)

Check below how Assist Soluções em TI used Scriptcase to modernize and streamline the development...

You might also like…

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.