
Unix 타임스탬프는 주로 Unix 운영 체제에서 사용됩니다. 하지만 모두에게 도움이 됩니다
운영 체제는 모든 시간대의 시간을 나타냅니다.
Unix 타임스탬프는 시간을 초 단위로 나타냅니다. 유닉스 시대는 1일부터 시작된다
1970년 1월.
그래서 Unix 타임스탬프는 특정 날짜 사이의 초 수입니다.
Example
DateTime.Now.Subtract를 사용하여 Unix 타임스탬프()를 가져옵니다.총 초
DateTimeOffset.Now.ToUnixTimeSeconds()를 사용하여 Unix 타임스탬프를 가져오는
1 2 3 4 5 6 7 8 | class Program{
static void Main(string[] args){
Int32 unixTimestamp = (Int32)(DateTime.Now.Subtract( new
DateTime(1970, 1, 1))).TotalSeconds;
Console.WriteLine( "The Unix Timestamp is {0}" , unixTimestamp);
Console.ReadLine();
}
}
|
로그인 후 복사
Output
Example
메서드
1 2 3 4 5 6 7 | class Program{
static void Main(string[] args){
var unixTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds();
Console.WriteLine( "The Unix Timestamp is {0}." , unixTimestamp);
Console.ReadLine();
}
}
|
로그인 후 복사
위 내용은 C#에서 Unix 타임스탬프를 얻는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!