Create a date instance, PHP Web Programming

Assignment Help:

The Date object is utilized to work with dates & times.

Creating a Date Instance

You must create an instance of the Date object along with the "new" keyword. The following line of code stores the current date into a variable called "my_date":

var my_date=new Date( )

After making an instance of the Date object, you can access all of the methods of the object from the "my_date" variable. If, for instance, you desire to return the date (from 1-31) of a Date object, you must write the following:

        my_date.getDate( )

You may also write a date within the parentheses of the Date( ) object. The following line of code illustrates some of the date formats obtainable.

new Date("Month dd, yyyy hh:mm:ss"), new Date("Month dd, yyyy"), new

Date(yy,mm,dd,hh,mm,ss), new Date(yy,mm,dd), new Date(milliseconds)

Here is how you can develop a Date object for each ways above:

var my_date=new Date("march 22, 1988 13:14:00"), var my_date=new Date("march 22, 1989"), var my_date=new Date(89,03,22,13,14,00), var my_date=new Date(89,03,22), var my_date=new Date(500)

• Some Date Methods

Methods

Explanation

Date( )

Returns Date object

GetDate( )

Returns the date of Date object (from 1-31)

GetDay( )

Returns the day of Date object (from 0-6. 0=Monday,

1=Sunday, etc.)

GetMonth( )

Returns the month of Date object (from 0-11. 0=December,

1=January, etc.)

GetFullYear( )

Returns the year of the Date object (four digits)

GetHours( )

Returns the hour of the Date object (from 0-23)

GetMinutes( )

Returns the minute of the Date object (from 0-59)

GetSeconds( )

Returns the second of the Date object (from 0-59)

 


Related Discussions:- Create a date instance

We need an e-commerce web developer, We need an E-commerce web developer ...

We need an E-commerce web developer Adopt, develop as well as deploy scalable and appropriate website solutions using the (customization) framework • Produce Digital Consumer

View the site files, To see a high-level representation of the structure of...

To see a high-level representation of the structure of a local site, you use Dreamweaver's Site Map view. You can also employ the site map to insert new files to the site, to add,

Need help in wordpress site with e-commerce integration, WordPress Site wit...

WordPress Site with E-Commerce Integration We want development of a site in Word Press. We will offer the designs and the content. We will want you to set up the site and conver

Need help in magento site optimization, Need help in Magento Site Optimizat...

Need help in Magento Site Optimization and Cross Browser Compatibility Looking for Magento expert for optimization of development site due to be launched soon. Tasks would compr

Briefly describe open source technologies, Question: (a) Briefly descri...

Question: (a) Briefly describe open source technologies, outlining the difference between open source technologies and free technologies. (b) Show advantages of using open

Need help in personal account component for joomla, Personal account compon...

Personal account component for Joomla It is essential to develop a component for CMS Joomla which will permit visitors of a site to receive necessary information of financial ch

We need website developer, Website Developer We are currently looking fo...

Website Developer We are currently looking for a web site developer. Job Description- We're looking for a Web Developer. Your responsibilities- a) Review business re

Format text, You can format text into the Document window through setting p...

You can format text into the Document window through setting properties in the Property inspector. First one, choose the text you desire to format, and then apply the modification.

Cell spacing and cell padding, Let us notice at a couple of attributes call...

Let us notice at a couple of attributes called CELLSPACING and CELLPADDING. Both are part of the tag. CELLPADDING is the amount of space among the border of the cell

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd