php-mysql tutorial

Designed By NISHANT GUPTA

  • Home
  • PHP
  • HTML
  • CSS
  • JavaScript
  • JQuery
  • Contact-us
  • Learn HTML

    • Introduction of HTML
    • Image Handling in HTML
    • List Handling in HTML
    • Font Handling in HTML
    • Table Handling in HTML
    • Form Handling in HTML
  • Learn CSS

    • Introduction of CSS
    • Styling Background in CSS
    • Styling Text in CSS
    • Styling Font in CSS
    • Styling Link in CSS
    • Styling List in CSS
    • Styling Table in CSS
    • Styling Div in CSS
    • Styling Span in CSS
    • Positioning in CSS
    • Display in CSS
  • Learn JavaScript

    • Introduction of JavaScript
    • Data Type in JavaScript
    • Variable in JavaScript
    • Oprator in JavaScript
    • Cond. Statement in JavaScript
    • Loop in JavaScript
    • Array in JavaScript
    • Function in JavaScript
    • Date in JavaScript
    • String in JavaScript
    • DOM in JavaScript
    • Event Handling in JavaScript
    • Form Handling in JavaScript
  • Learn PHP-MYSQL

    • Introduction of PHP
    • Decision Control in PHP
    • Loop in PHP
    • Array in PHP
    • Function in PHP
    • Form Handling in PHP
    • File Inclusion in PHP

Date in JavaScript

The Date Object

The Date object is used to work with date and time.It is used for 2 tasks:

  1. Storing dates and time
  2. Retrieve current date and time

Date Constructors

  1. Date( ): This creates a Date object with the current date and time of browser’s PC.

    var now=new Date( );

  2. Date(“Month dd,yyyy”)

    var now;

    now=new Date(“February 4,2013”);

  3. Date(yy,mm,dd)

    var now;

    now=new Date(13,2,4);

  4. Date(“Month dd,yyyy hh:mm:ss” ):

    var now;

    now=new Date(“February 4,2013 17:45:00”);

  5. Date(yy,mm,dd,hh,mm,ss)

    var now;

    now=new Date(13,2,4,17,45,0);

  6. Date(milliseconds) Creates a date object with the date value represented by number of milliseconds passed since midnight Jan 1,1970

    var now;

    now=new Date(500);

Using Date Methods

  1. getDate( ) Returns day of the month.
  2. getDay( ) Returns day of the week from 0 to 6.
  3. getFullYear( ) Returns year with 4 digits.
  4. getMonth( ) Returns month from 0 to 11.
  5. getHours( ) Returns the hour (0 to 23).
  6. getMinutes( ) Returns the minute component.
  7. getSeconds( ) Returns the seconds component.
  8. toString( ) Returns the string representation of Date object

    var d=new Date();
    var str=d.toString();

    The result of str will be:

    Mon Feb 04 2013 12:30:59 GMT+0530 (India Standard Time)

  9. toDateString( ) Returns the string representation of date portion of Date object

    var d=new Date();
    var str=d.toDateString();

    The result of str will be:

    Mon Feb 04 2013

  10.  toTimeString( ) Returns the string representation of time  portion of Date object

    var d=new Date();
    var str=d.toTimeString();

    The result of str will be:

    12:33:39 GMT+0530 (India Standard Time)

 

Advertisements

 

©  2014 All Rights Reserved  •  Design by >Nishant Gupta.

Privacy Policy • Terms of Use