Click here to Skip to main content
15,886,631 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi i want get datetime in c# with pattern
"yyyy/MM/dd HH:mm:ss:ff"

and then i want to reduce 3 second of this time
how can i do this?
?????????

tnx
Posted
Comments
Philippe Mori 3-Sep-11 20:50pm    
A bit more effort would not hurt as it is easy to find that information in the help.

Formats are documented in the help with an example for each format specifier. It is pretty easy to find help on that by searching DateTime format.

Standard Date and Time Format Strings[^]

Custom Date and Time Format Strings[^]

And the last question is also easy to answer from the help.

C#
var timeLess3Seconds = originalTime.AddSeconds(-3.0);
 
Share this answer
 
You can't subtract in a format string. You'll have to subtract those three seconds from your actual DateTime value e.g. myDateTime = myDateTime.AddSeconds(-3);
 
Share this answer
 

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