Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i using following code

DateTime firstDateTime = DateTime.Parse("9:30 AM");
DateTime secondDateTime = DateTime.Parse("6:30 PM");
TimeSpan diff;
diff= secondDateTime.Subtract(firstDateTime);

here i found wrong answer in - sign and value.
what i do Please Help?
Posted
Comments
MuhammadUSman1 30-Nov-13 0:31am    
I copy your code and check in visual studio,
and got 100% Accurate answer [09:00:00] i don't know what you expecting.

What Do you mean by "here i found wrong answer in - sign and value"?

before calculate convert it to 24 hours the get time diff, just a hint
 
Share this answer
 
Comments
phil.o 30-Nov-13 1:10am    
There is no conversion between 12 and 24 hours format ; these are just two ways of displaying the same value.
Refer this article
Time Period Library for .NET[^]
 
Share this answer
 
Already Solved. Not needed convert time in 24 hrs.
 
Share this answer
 
Comments
phil.o 30-Nov-13 1:11am    
Not an answer.
If this is solved, you should have marked it so.

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