How to get the total number of days in a year from the given date

后端 未结 5 1014
别跟我提以往
别跟我提以往 2021-01-05 00:24

I would like to get the total number of days in a year left from the given date .. Assume if a user gives 04-01-2011(MM-DD-YYYY) I would like to find the remain

5条回答
  •  再見小時候
    2021-01-05 00:39

    I think you should try TimeSpan like

     DateTime startTime = DateTime.Now;
    
     DateTime endTime = DateTime.Now.AddSeconds( 75 );
    
     TimeSpan span = endTime.Subtract ( startTime );
     Console.WriteLine( "Time Difference (seconds): " + span.Seconds );
     Console.WriteLine( "Time Difference (minutes): " + span.Minutes );
     Console.WriteLine( "Time Difference (hours): " + span.Hours );
     Console.WriteLine( "Time Difference (days): " + span.Days );
    

提交回复
热议问题