Unity获取时间戳

 

    private System.DateTime ConvertLongToDateTime( long timeStamp )
    {
        System.DateTime dtStart = System.TimeZone.CurrentTimeZone.ToLocalTime( new System.DateTime( 1970, 1, 1 ) );
        long lTime = long.Parse( timeStamp + "0000000" );
        System.TimeSpan toNow = new System.TimeSpan( lTime );
        return dtStart.Add( toNow );
    }
 
    private long ConvertDateTimeToLong( System.DateTime time )
    {
        System.DateTime startTime = System.TimeZone.CurrentTimeZone.ToLocalTime( new System.DateTime( 1970, 1, 1 ) );
        return (long)( time - startTime ).TotalSeconds;
    }

 

你可能感兴趣的:(Unity3D,C#)