.net core unix timestamp and local time conversion, to get the current timestamp

Get the current timestamp, the timestamp is converted to the current local time

        ///  <Summary> 
        ///   stamp transfer local time - accurate to the second stamp
         ///  </ Summary>  
        public  static the DateTime ToLocalTimeDateBySeconds ( Long UNIX) 
        { 
            var DTO = DateTimeOffset.FromUnixTimeSeconds (UNIX);
             return dto.ToLocalTime () .DateTime; 
        } 

        ///  <Summary> 
        ///   time stamp transferred to the second accurate time stamp Unix-
         ///  </ Summary>  
        public  static  Long ToUnixTimestampBySeconds (the DateTime dt) 
        { 
            the DateTimeOffset DTO = new new the DateTimeOffset (dt) ;
            return dto.ToUnixTimeSeconds (); 
        } 


        ///  <Summary> 
        ///   stamp transfer local time - timestamp to the millisecond
         ///  </ Summary>  
        public  static the DateTime ToLocalTimeDateByMilliseconds ( Long UNIX) 
        { 
            var DTO = DateTimeOffset.FromUnixTimeMilliseconds (UNIX);
             return dto.ToLocalTime () the DateTime;. 
        } 

        ///  <Summary> 
        ///   time stamp transferred to the millisecond timestamp Unix-
         ///  </ Summary>  
        public  static  Long ToUnixTimestampByMilliseconds (the DateTime dt) 
        { 
            the DateTimeOffset dto= new DateTimeOffset(dt);
            return dto.ToUnixTimeMilliseconds();
        }

 

Guess you like

Origin www.cnblogs.com/linJie1930906722/p/12516726.html