I have a developed a web application . Now i am testing it in the localhost. It deals with time . There is a date picker javascript which reads date in MM/DD/YYYY format. But my system format is different. When Converting to Datetime is gives error. string
is not a valid date time format.
how to solve it.
Thanks in advance
Enjoy the world of coding !!! it is not boring as you heard.!! Give your hear and mind to Enjoy this awesome world .
I have a developed a web application . Now i am testing it in the localhost. It deals with time . There is a date picker javascript which reads date in MM/DD/YYYY format. But my system format is different. When Converting to Datetime is gives error. string
is not a valid date time format.
i already have in mm/dd/yyyy format. The problem is my system format. it is dd-mmm-yyyy format. When i use Convert.ToDateTime method. It is converting wrong.
For example - 1/10/2012 (jan 10 2012) to 1 oct 2012
I need this in 1/10/2012 format itself
I have the date format in
shivalthakur
itsvineethpv
Dear Friends,
I have a developed a web application . Now i am testing it in the localhost. It deals with time . There is a date picker javascript which reads date in MM/DD/YYYY format. But my system format is different. When Converting to Datetime is gives error. string
is not a valid date time format.
itsvineethpv
Member
142 Points
144 Posts
Date time format
Apr 10, 2012 04:32 AM|LINK
Dear Friends,
I have a developed a web application . Now i am testing it in the localhost. It deals with time . There is a date picker javascript which reads date in MM/DD/YYYY format. But my system format is different. When Converting to Datetime is gives error. string is not a valid date time format.
how to solve it.
Thanks in advance
shivalthakur
Participant
1837 Points
531 Posts
Re: Date time format
Apr 10, 2012 05:05 AM|LINK
hi try this
IFormatProvider fp=new CultureInfo("es-PA"); string mydate = "01/31/2012"; DateTime dt= DateTime.Parse(mydate,fp);hope this will help
Response.Write("Success");
Best Of Luck
Shival Thakur
coolpal9
Member
150 Points
520 Posts
Re: Date time format
Apr 10, 2012 05:13 AM|LINK
Use
DataFormatString="{0:d}"
Srikanth Kas...
Contributor
4289 Points
883 Posts
Re: Date time format
Apr 10, 2012 05:19 AM|LINK
Srikanth Kasturi
Please "Mark As Answer" if my post serves purpose.
itsvineethpv
Member
142 Points
144 Posts
Re: Date time format
Apr 10, 2012 05:25 AM|LINK
I used this,
IFormatProvider fp = new CultureInfo("es-PA");
DateTime x = Convert.ToDateTime(txtdate.Text, fp );
Not worked.
X is still in my system date format dd-mmm-yyyy
shivalthakur
Participant
1837 Points
531 Posts
Re: Date time format
Apr 10, 2012 05:33 AM|LINK
i think this is what you want.
IFormatProvider fp=new CultureInfo("es-PA"); string mydate = "01/31/2012"; DateTime dt= DateTime.Parse(mydate,fp); Response.Write(dt.ToString("d", fp));Thanks
Response.Write("Success");
Best Of Luck
Shival Thakur
Jack Hunt
Participant
1266 Points
708 Posts
Re: Date time format
Apr 10, 2012 05:44 AM|LINK
u can set US culture in your application and set culture and than try it
mit's Website
Mitesh N Vaishnav
itsvineethpv
Member
142 Points
144 Posts
Re: Date time format
Apr 10, 2012 05:45 AM|LINK
No dear friend,
i already have in mm/dd/yyyy format. The problem is my system format. it is dd-mmm-yyyy format. When i use Convert.ToDateTime method. It is converting wrong.
For example - 1/10/2012 (jan 10 2012) to 1 oct 2012
I need this in 1/10/2012 format itself
I have the date format in
Jack Hunt
Participant
1266 Points
708 Posts
Re: Date time format
Apr 10, 2012 05:48 AM|LINK
change your system's dateformat to MM/dd/yyyy ,
i also get that type of error and than solved like this
your system has definitely dd/MM/yyyy format so check it out that
mit's Website
Mitesh N Vaishnav
itsvineethpv
Member
142 Points
144 Posts
Re: Date time format
Apr 10, 2012 05:51 AM|LINK
hey friend,
this is a windows application. when the end user use it. it will create error, if using different time format.right?