hi,
i have string like 20110831 but i want to show this like 8/31/2011(mm/dd/yyyy) in javascript. Please help me.
thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Sep 7, 2011, 7:02 AM
Try this
Thanks
If this post helps you mark it as answer
nitin yadavPosted Sep 7, 2011, 7:05 AM
Prabhu RajaPosted Sep 7, 2011, 6:33 AM
var datevalue1 = "20110831";
var day1 = datevalue1.substring(6, 8);
var month1 = datevalue1.substring(4, 6 );
var year1 = datevalue1.substring(0, 4);
var d1 = month1 + "/" + day1 + "/" + year1;
alert(d1 );
--------------------------------------------
If it helps you, Mark as "correct answer"
Vilas GitePosted Sep 7, 2011, 6:28 AM
Hi Nitin!
Refer
http://bytes.com/topic/javascript/answers/519332-how-convert-datetime-format-using-javascript
http://stackoverflow.com/questions/476105/how-can-i-convert-string-to-datetime-with-format-specification-in-javascript
Thanks!
-----------------------------------------------------------------------
If this reply helps your post…then check "This is correct answer"
nitin yadavPosted Sep 7, 2011, 6:22 AM
Prabhu RajaPosted Sep 7, 2011, 6:06 AM
Try this.
var dat=Date.parse("20110831");
var theDate = new Date(dat);
-----------------------------------------------
If it helps you, then mark it as "Correct Answer"