Condition:
There is a current date - DateTime current = DateTime.Now;
There is a date of birth - DateTime BirthDate = new DateTime(1970, 04, 06);
Task: Display a variable for calculating the elapsed time from BirthDate to current
Condition:
There is a current date - DateTime current = DateTime.Now;
There is a date of birth - DateTime BirthDate = new DateTime(1970, 04, 06);
Task: Display a variable for calculating the elapsed time from BirthDate to current
Just subtract the date of birth from the current date and get the result in TimeSpan :
var t = BirthDate - current; The DateTime structure has a specially overloaded operator for it: public static TimeSpan operator - (DateTime d1, DateTime d2)
ToString . Just pick the right format string. - VladDTranslate both dates in the timestamp, then subtract the birth date from the current one https://stackoverflow.com/questions/17632584/how-to-get-the-unix-timestamp-in-c-sharp
You will get the result in milliseconds, then proceed according to circumstances.
Source: https://ru.stackoverflow.com/questions/750717/
All Articles