Hi,
I have tried so far is $("#txtAddedDate").val(data.d.AddedDate);. But its output will be /Date(1415212200000)/. I need it in 03/06/2014 format.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Anupam SinghRank #643 · 3.7K reputationPosted Jun 19, 2014, 1:33 AM EDT
var datecheck=data.d.AddedDate;
$("#txtAddedDate").val((datecheck.getMonth() ) + '/' + datecheck.getDate() + '/' + datecheck.getFullYear()))
not tested.
Renjith V SRank #5,293 · 304 reputationPosted Jun 19, 2014, 1:45 AM EDT
Akhil MittalRank #133 · 16.9K reputationPosted Jun 19, 2014, 2:06 AM EDT
$("#txtAddedDate").val((datecheck.Day ) + '/' + datecheck.Month + '/' + datecheck.Year))
Anupam SinghRank #643 · 3.7K reputationPosted Jun 19, 2014, 2:11 AM EDT
try this :
it should work.
Renjith V SRank #5,293 · 304 reputationPosted Jun 19, 2014, 3:47 AM EDT
I have tried your answer but the output is
NaN/NaN/NaN
Anupam SinghRank #643 · 3.7K reputationPosted Jun 19, 2014, 3:51 AM EDT
Actually I tried this :
it means $("#txtAddedDate").val(data.d.AddedDate) has incorrect value.so you have to correct this.
if you will try above code, will work fine.
Renjith V SRank #5,293 · 304 reputationPosted Jun 19, 2014, 3:57 AM EDT
Still the same problem
Anupam SinghRank #643 · 3.7K reputationPosted Jun 19, 2014, 4:03 AM EDT
put script this at last .And if you are getting value in txtAddedDate it will display correct format.
best of luck !
Renjith V SRank #5,293 · 304 reputationPosted Jun 19, 2014, 10:12 PM EDT
Your answer is correct but I found an alternative it works me well.
data.d.AddedDate is in json format.
use this function to convert date
$("#txtAddedDate").val(jsonDateformat(data.d.AddedDate));
function jsonDateformat(date) {
jsonDate = date;
var d = new Date(parseInt(jsonDate.substr(6)));
var m, day;
m = d.getMonth() + 1;
if (m < 10)
m = '0' + m
if (d.getDate() < 10)
day = '0' + d.getDate()
else
day = d.getDate();
var formattedDate = m + "/" + day + "/" + d.getFullYear();
var hours = (d.getHours() < 10) ? "0" + d.getHours() : d.getHours();
var minutes = (d.getMinutes() < 10) ? "0" + d.getMinutes() : d.getMinutes();
var formattedTime = hours + ":" + minutes + ":" + d.getSeconds();
formattedDate = formattedDate + " " + formattedTime;
return formattedDate;
}