使用格式以毫秒为单位获取c#中的时间 [英] get time in c# with millisecond with format
本文介绍了使用格式以毫秒为单位获取c#中的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
"yyyy/MM/dd HH:mm:ss:ff"
获取日期时间
然后我想减少3秒钟的时间
我该怎么办?
?????????
tnx
解决方案
帮助中记录了格式,并为每个格式说明符提供了示例.通过搜索DateTime format
可以很容易地找到帮助.
标准日期和时间格式字符串 [自定义日期和时间格式字符串 [ var timeLess3Seconds = originalTime.AddSeconds(-3. 0 );
您不能减去格式字符串.您必须从实际的DateTime
值中减去这三秒,例如myDateTime = myDateTime.AddSeconds(-3);
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
解决方案
Formats are documented in the help with an example for each format specifier. It is pretty easy to find help on that by searchingDateTime 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);
You can''t subtract in a format string. You''ll have to subtract those three seconds from your actualDateTime
value e.g.myDateTime = myDateTime.AddSeconds(-3);
这篇关于使用格式以毫秒为单位获取c#中的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文