Java Script: Get current date and time in java script yyyy-mm-dd hh:mm format.

In javascript when we var d = new Date(); and alert(d) then we get date in format “Tue Dec 04 2012 13:06:47 GMT+0530 (India Standard Time)” Some time we need date and time in different format in my case i need : yyyy-mm-dd hh:mm below is code which output
current date format in this format 2012-11-27 11:16


function GetCurrentDate() {
        // Today date time which will used to set as default date.
        var todayDate = new Date();
        todayDate = todayDate.getFullYear() + "-" +
                       ("0" + (todayDate.getMonth() + 1)).slice(-2) + "-" +
                       ("0" + todayDate.getDate()).slice(-2) + " " + ("0" + todayDate.getHours()).slice(-2) + ":" +
                       ("0" + todayDate.getMinutes()).slice(-2);

        return todayDate;
    }

Another Article

C#: How to Serialize JSON Array data by c# on server side.
How to Create Drag and Drop By J query.
How to get Dragable or Dropable element ID or attribute value in J-Query.
How to call server side method by jquery or java script in asp.net.
How to add javascript file by c# code in asp.net page.
Java Script: How to Get asp.net hidden or input field value by java script/ j-Query.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s