Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
182
rated 0 times [  184] [ 2]  / answers: 1 / hits: 50368  / 12 Years ago, tue, april 17, 2012, 12:00:00

I have a json date like /Date(1334514600000)/ in my response and when I convert it in javascript then I got this date Tue Apr 17 2012 11:37:10 GMT+0530 (India Standard Time),
but I need the date format like 17/04/2012 and I fail every time. Can anyone tell me how can I resolve it?


More From » json

 Answers
8

I don't think that the other posted answers are quite right, you have already accepted one as working for you so I won't edit it.



Here is an updated version of your accepted answer.



var dateString = /Date(1334514600000)/.substr(6);
var currentTime = new Date(parseInt(dateString ));
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var date = day + / + month + / + year;
alert(date);


It uses a technique from this answer to extract the epoch from the JSON date.


[#86196] Sunday, April 15, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nathalieg

Total Points: 462
Total Questions: 106
Total Answers: 93

Location: Turks and Caicos Islands
Member since Tue, Mar 30, 2021
3 Years ago
nathalieg questions
;