Click here to Skip to main content
15,306,032 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I made a simple Employee Presence Application (actually this is happening with every applications I make. I am new to C#.). When I tried to run it on other machine it didn't run and gave an error of Invalid dateTime. So I changed DateTime Format of that machine same as mine. It ran successfully. So what can I do. I don't want to change datetime format on every machines.
Posted
Comments
   
Not a question. Why could not you change it?
--SA

1 solution

The problem is not clear. With .NET, you can read time in any format and produce any format on output. Please see the number of methods Parse, ParseExact, TryParse, TryParseExact and ToString:
http://msdn.microsoft.com/en-us/library/system.datetime.aspx[^].

For format specifiers, please see:
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx[^],
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[^].

Besides, make sure you parse from string and output data to string only when it is really required. I saw many questions where the inquirers tend to work with strings representing data instead of data itself. This is totally wrong approach.

—SA
   
Comments
__TR__ 30-Nov-12 1:32am
   
My 5!
   
Thank you.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900