Click here to Skip to main content
12,352,167 members (30,255 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# C#4.0
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 3-Sep-11 13:40pm
jiji26631.9K
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.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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.

var timeLess3Seconds = originalTime.AddSeconds(-3.0);
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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);
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 3 Sep 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100