Convert Json Date String To Date Format In jQuery
15:51Introduction
In this post I want to show, how to Convert json date to date format in jQuery.Problem
Suppose you want to convert '/Date(1448583916000)/' to datetime format in jquerySolution
Follow this function: function dateTimeFormat(dateTimeValue)
{
var dt = new Date(parseInt(dateTimeValue.replace(/(^.*\()|([+-].*$)/g, '')));
var dateTimeFormat = dt.getDate() + "/" + (dt.getMonth() + 1) + "/" + dt.getFullYear();
return dateTimeFormat;
}
Now if we want to convert '/Date(1448583916000)/' to 'dd/mm/yyyy' format.
Out Put
27/11/2015If You Want Time
function dateTimeFormat(dateTimeValue)
{
var dt = new Date(parseInt(dateTimeValue.replace(/(^.*\()|([+-].*$)/g, '')));
var dateTimeFormat = dt.getDate() + "/" + (dt.getMonth() + 1) + "/" + dt.getFullYear() + ' ' + dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
return dateTimeFormat;
}

0 comments