473,405 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

System.FormatException: String was not recognized as a valid DateTime.

Hi all,
i have created a web application on my location (India) and when i run the application it's run fine, but when i host this application in autralia then the above errors occours by the following line

DateTime WhenDtg = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"));


i am not getting the solution.
Oct 23 '07 #1
4 2774
Hi all,
i have created a web application on my location (India) and when i run the application it's run fine, but when i host this application in autralia then the above errors occours by the following line

DateTime WhenDtg = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"));


i am not getting the solution.
my guess is, its a Culture issue, a date's format in India is not the same as in Australia.

Read the following: Developing World Ready Applications,

theres a part in that section where it talks about formatting Date and Time for a Specific Culture.
Oct 23 '07 #2
my guess is, its a Culture issue, a date's format in India is not the same as in Australia.

Read the following: Developing World Ready Applications,

theres a part in that section where it talks about formatting Date and Time for a Specific Culture.

i had also change the culture but the problem remain the same.
Oct 23 '07 #3
Plater
7,872 Expert 4TB
Question:
Whay are you doing that line at all?

Expand|Select|Wrap|Line Numbers
  1. DateTime WhenDtg = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"));
  2.  
All you're doing there is taking a DateTime object, making it a string, then trying to make it a DateTime object again. That is a big waste. DateTime is not stored "in a format", that is just for displaying purposes.

Expand|Select|Wrap|Line Numbers
  1. DateTime WhenDtg = DateTime.Now;
  2.  
Oct 23 '07 #4
yeah, Plater has a good point there...no need to do that.
Oct 23 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
14
by: Jon Davis | last post by:
I have put my users through so much crap with this bug it is an absolute shame. I have a product that reads/writes RSS 2.0 documents, among other things. The RSS 2.0 spec mandates an en-US style...
3
by: Patrick Olurotimi Ige | last post by:
I moved some projects to another server and using the code below i get the error:- "String was not recognized as a valid DateTime" <asp:Label runat="server" width="40%" text=' <%#...
0
by: RSH | last post by:
I am having a bit of trouble filling a datatable with a query. I'm getting the error message: System.FormatException: String was not recognized as a valid DateTime. at...
6
by: Rookie Card | last post by:
I know this is a very common issue but cannot find a thread that resolves the issue. I need to re-format my dates to "MMM d, yyyy". The problem I have is I have an MSSQL database that allows...
1
by: database | last post by:
I AM FACING A PROBLEM WHEN I ACCESS ONE OF THE PAGES. IT USED TO WORK BEFORE BUT AFTER RESTARTING THE APPLICATION SEVER IT GIVES THE FOLLOWING ERROR. - Server Error ...
10
by: mercea | last post by:
hi all, i'm trying to insert the time/date a button was clicked on a gridview and it generates an error:the string was not recognized as a valid DateTime.There is an unknown word starting at index 0...
4
by: dhanashivam | last post by:
hi, in my web application i am getting date values from sql server database and store in the datatable. it works fine when i use the US culture. But when i change the culture to british i am...
3
by: lucindaa | last post by:
Hi, i have a string variable having date as following format "05-01-2010" when convert this date into DateTime Format i got the following error 'String was not recognized as a valid DateTime'...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.