Ignore milliseconds when comparing two datetimes

前端 未结 14 2158
一个人的身影
一个人的身影 2020-12-08 12:47

This is probably a dumb question, but I cannot seem to figure it out. I am comparing the LastWriteTime of two files, however it is always failing because the file I download

相关标签:
14条回答
  • 2020-12-08 13:34
    TimeSpan difference = dtNew - dtOrig;
    if (difference >= TimeSpan.FromSeconds(1))
    {
        ...
    }
    
    0 讨论(0)
  • 2020-12-08 13:35

    Create a new DateTime value with the milliseconds component set to 0:

    dt = dt.AddMilliseconds(-dt.Millisecond);
    
    0 讨论(0)
提交回复
热议问题