Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: 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.7K
Comments
Philippe Mori at 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
0 Sergey Alexandrovich Kryukov 360
1 Gihan Liyanage 332
2 ClimerChinna 222
3 OriginalGriff 206
4 Richard MacCutchan 170
0 Sergey Alexandrovich Kryukov 8,298
1 OriginalGriff 7,112
2 CPallini 2,598
3 Richard MacCutchan 2,005
4 Abhinav S 1,788


Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 3 Sep 2011
Copyright © CodeProject, 1999-2014
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