I would like to store the current time as an integer, re perl. I know I need a TimeSpan, starting from windows time start. I know windows time starts from when?, Jan 1st, 1601.
scope_creep
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Does it HAVE to be an integer? Could it be a long? If so, the easy answer is to use the
.Ticksproperty on aDateTimeobject.You can also get the “minimum” DateTime supported from the
MinValueproperty. You could then use the normal subtraction operator to get a TimeSpan difference between two DateTimes.Also, storing times as integers can be tricky, because the maximum (unsigned) int value can only store about 136 years. If you need resolution beyond that, you need to use long, or at least make sure you pick your starting date appropriately.
UPDATE: To address your comments, you could store the time and then calculate seconds like such: