How to change date format from ddmmyyyy to default format through Javascript - Stack Overflow

In my Database i am having date in "ddmmyyyy" format. In the sucess function I am getting l

In my Database i am having date in "dd/mm/yyyy" format. In the sucess function I am getting like '29/06/2006". I want to convert this form "dd/mm/yyyy" format to default format (default format means "Thu Jun 29 2006 00:00:00 GMT+0530 (India Standard Time)")

I tried the following ways

1) way

xx = 29/06/2006 
new Date(xx)

2)way

dateFormat(xx, "ddd, mmmm dS, yyyy, h:MM:ss TT")

Both giving wrong date,month,year. Result as (Tue, May 6th, 2008, 12:00:00 AM)

I am giving input as Jun 29 2006 but after conversion it'a showing May 6th, 2008.

In my Database i am having date in "dd/mm/yyyy" format. In the sucess function I am getting like '29/06/2006". I want to convert this form "dd/mm/yyyy" format to default format (default format means "Thu Jun 29 2006 00:00:00 GMT+0530 (India Standard Time)")

I tried the following ways

1) way

xx = 29/06/2006 
new Date(xx)

2)way

dateFormat(xx, "ddd, mmmm dS, yyyy, h:MM:ss TT")

Both giving wrong date,month,year. Result as (Tue, May 6th, 2008, 12:00:00 AM)

I am giving input as Jun 29 2006 but after conversion it'a showing May 6th, 2008.

Share Improve this question edited Aug 16, 2011 at 8:10 pyvi 6751 gold badge4 silver badges16 bronze badges asked Aug 16, 2011 at 8:01 vinothinivinothini 2,6044 gold badges29 silver badges42 bronze badges 1
  • There is a similar question about this at stackoverflow./questions/476105/… – zaboco Commented Aug 16, 2011 at 9:20
Add a ment  | 

3 Answers 3

Reset to default 1

Try this:

var mydate = new Date(getDateFromFormat(/*Date value in string*/, /*Format of date sting*/));

http://www.mattkruse./javascript/date/

check javascript dateFormat

this could do it:

var dt  = '01/05/2011'.split(/\-|\s/)  // allows for 01-05-2011 also
    dat = new Date(dt.reverse().join('/'));

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745199030a4616234.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信