Check out example codes for "c# get time". It will help you in understanding the concepts better.

Code Example 1

//Return the time from DateTime object in string format
var timeString = DateTime.Now.ToString("hh:mm:ss");

//Return time in 24h format
var time24 = DateTime.Now.ToString("HH:mm:ss");
//Use short time format to return string value
var timeString = DateTime.Now.ToString("t");
var shortTimeStr = DateTime.Now.ToShortTimeString();

//Use long time format
var longTimeStr = DateTime.Now.ToLongTimeString();
var longtimestr = DateTime.Now.ToString("T");

//Return a TimeSpan from midnight
var timeSpan = DateTime.Now.TimeOfDay;

Code Example 2

DateTime now = DateTime.Now;

Code Example 3

DateTime a = ;//some datetime
DateTime now = DateTime.Now;
TimeSpan ts = now-a;

Learn ReactJs, React Native from