Tuesday, December 25, 2012

Date Display

Date Function

This post illustrate as how to display the current date on a button click.The date format that I have used in the below example is dd/mm/yyyy. we can imply different formats.

1. Add the below code in the body section of the HTML file.

<input type="text" id="dis" /><br />

<input type="button" value="Display Date" onclick="display()" />

2. Add the below script in the .js file or you could implement the script in the head section of the HTML file.

function display(){
var x="You have clicked";
var d=new Date();
var date=d.getDate();
var month=d.getMonth();
var year=d.getFullYear();

Hope this post was informative. Will get back with more posts shortly.

Informative Javascript

1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me..I am a regular follower of your blog.
    Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from HTML5 CSS3 Javascript Online Training from India .
    or learn thru HTML5 CSS3 Javascript Online Training from India. Nowadays JavaScript has tons of job opportunities on various vertical industry. HTML5 CSS3 Javascript Online Training from India