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.
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
Satyapriya NayakRank #47 · 31.5K reputationPosted Sep 7, 2011, 3:02 AM EDT
Try this
Thanks
If this post helps you mark it as answer
Prabhu RajaRank #861 · 2.6K reputationPosted Sep 7, 2011, 2:06 AM EDT
Try this.
var dat=Date.parse("20110831");
var theDate = new Date(dat);
-----------------------------------------------
If it helps you, then mark it as "Correct Answer"
nitin yadav100 reputationPosted Sep 7, 2011, 2:22 AM EDT
Vilas GiteRank #951 · 2.1K reputationPosted Sep 7, 2011, 2:28 AM EDT
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"
Prabhu RajaRank #861 · 2.6K reputationPosted Sep 7, 2011, 2:33 AM EDT
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"
nitin yadav100 reputationPosted Sep 7, 2011, 3:05 AM EDT