Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert from "TimeSpan" to "Long"

How can I convert a timespan datatype to a long?

like image 867
panipsilos Avatar asked Jan 26 '26 20:01

panipsilos


2 Answers

Assuming you use .NET, Use:

MyTimeSpan.Ticks()

and to convert back (sample in VB.NET, C# implementation is trivial nontheless):

MyTimeSpan = New TimeSpan(totalTicks)
like image 191
M.A. Hanin Avatar answered Jan 29 '26 08:01

M.A. Hanin


Actually you must use

MyTimeSpan.Ticks;

instead

MyTimeSpan.Ticks();
like image 33
Guilherme Campos Avatar answered Jan 29 '26 10:01

Guilherme Campos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!