Wednesday, 23 May 2012

Convert date format in javascript

    Here in this example i am going to explain how to convert date into another format in javascript.

Example :

Here in this today's date will be obtained in the variable dt in system format and on TodayDate variable we will get the date in required format. The example formats are:
var dt = new Date();
var TodayDate = dt.format("M/d/yyyy");
var TodayDate = dt.format("M/d/yy");
var TodayDate = dt.format("MM/dd/yy");
var TodayDate = dt.format("yy/MM/dd");
var TodayDate = dt.format("yyyy-MM-dd");
var TodayDate = dt.format("dd-MMM-yy");
var TodayDate = dt.format("MM/dd/yyyy");


  1. This comment has been removed by a blog administrator.