당신은 날짜 개체를 가져 비교적 쉽게 비트를 구문 분석 할 수 있습니다, 당신이 원하는 형식으로 포맷 된 문자열을 만들 수 있습니다. 다음은 클라이언트와 다를 수있는 시간대를 고려한 것입니다.
var s = 'Mon Dec 31 2012 08:25:21 GMT+0100';
function getDate(s) {
// Split the string into bits
var s = s.split(/[ :]/);
// Conversion for month to month number (zero indexed)
var months = {jan:0,feb:1,mar:2,apr:3,may:4,jun:5,
jul:6,aug:7,sep:8,oct:9,nov:10,dec:11};
// Calculate the offset in minutes
var offsetMins = s[7].substring(4,6) * 60;
offsetMins += s[7].substring(6,8) * 1;
offsetMins *= s[7].substring(3,4) == '+'? 1 : -1;
// Build a UTC date value, allowing for the offset in minutes,
// and pass to the Date constructor
var date = new Date(Date.UTC(s[3], months[s[1].toLowerCase()],
s[2], s[4], (s[5] - offsetMins), s[6]));
// return the date object
return date;
}
function padN(n) {
return (n<10? '0' : '') + n;
}
var d = getDate(s);
alert(padN(d.getDate()) + '/' + padN(d.getMonth() + 1) + '/' + d.getFullYear());
이것이 시간대를 유지하는 가장 완벽한 대답이라고 생각합니다. 고맙습니다. – cyberfido