문제

From a weather feed I'm getting the data for dates in the form of 2012-05-17.

How do I convert that to Thursday May 17th form?

도움이 되었습니까?

해결책

  1. Parse the string into a JavaScript Date object.
  2. Format the Date object however you like.

See also: Why does Date.parse give incorrect results? and How to format a JavaScript date questions.

다른 팁

How about this:

var originalDateTime = '2012-05-17',
splitedDatetime = originalDateTime.split('0'),
date = new Date(),
date.setFullYear(splitedDatetime[0],splitedDatetime[1]-1,splitedDatetime[2]),
formatedDateString = date.toLocaleFormat("%A %B %d");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top