c# - How do I go about turning the time into a public int? -


how go turning time public int, kind of need convert timespan difference seconds , save public int.

as in 4 hours , 22 min , 34 seconds 15754.

    using unityengine;     using system.collections;     using system;      public class timeload : monobehaviour {           datetime  currentdate;          datetime  olddate;       void start()         {             //store current time when starts             currentdate = system.datetime.now;              //grab old time player prefs long             long temp = convert.toint64(playerprefs.getstring("sysstring"));              //convert old time binary datatime variable             datetime olddate = datetime.frombinary(temp);             print("olddate: " + olddate);              //use subtract method , store result timespan variable             timespan difference = currentdate.subtract(olddate);             print("difference: " + difference);       }      void onapplicationquit()     {         //savee current system time string in player prefs class         playerprefs.setstring("sysstring", system.datetime.now.tobinary().tostring());          print("saving date prefs: " + system.datetime.now);     }         } 

you can use totalseconds property:

//use subtract method , store result timespan variable             timespan difference = currentdate.subtract(olddate);             print("difference: " + difference.totalseconds); 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -