3C科技 娛樂遊戲 美食旅遊 時尚美妝 親子育兒 生活休閒 金融理財 健康運動 寰宇綜合

Zi 字媒體

2017-07-25T20:27:27+00:00
加入好友
C# UTC 和 Seconds(Milliseconds) 互轉 GITHUB: https://github.com/jash-git/CPP_CS_UTC2UTC2Seconds_project code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CS_UTC2Int64 { class Program { static void Pause() { Console.Write("Press any key to continue..."); Console.ReadKey(true); } static void Main(string[] args) { /* //https://docs.microsoft.com/zh-tw/dotnet/api/system.datetimeoffset.fromunixtimeseconds?view=net-5.0 DateTimeOffset offset = DateTimeOffset.FromUnixTimeSeconds(20); Console.WriteLine("DateTimeOffset = {0}", offset); Console.WriteLine("DateTimeOffset (other format) = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss}", offset); */ /* //https://docs.microsoft.com/zh-tw/dotnet/api/system.datetimeoffset.tounixtimeseconds?view=net-5.0 DateTimeOffset dto = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero); Console.WriteLine("{0} --> Unix Seconds: {1}", dto, dto.ToUnixTimeSeconds()); dto = new DateTimeOffset(1969, 12, 31, 23, 59, 0, TimeSpan.Zero); Console.WriteLine("{0} --> Unix Seconds: {1}", dto, dto.ToUnixTimeSeconds()); dto = new DateTimeOffset(1970, 1, 1, 0, 1, 0, TimeSpan.Zero); Console.WriteLine("{0} --> Unix Seconds: {1}", dto, dto.ToUnixTimeSeconds()); */ DateTimeOffset dto00 = new DateTimeOffset(DateTime.Now); Console.WriteLine("{0} --> Unix Seconds_00: {1}", dto00, dto00.ToUnixTimeSeconds());//long Console.WriteLine("{0} --> Unix Milliseconds_00: {1}", dto00, dto00.ToUnixTimeMilliseconds());//long Console.WriteLine(""); DateTimeOffset dto01 = new DateTimeOffset(DateTime.UtcNow);//https://currentmillis.com/ Console.WriteLine("{0} --> Unix Seconds_01: {1}", dto01, dto01.ToUnixTimeSeconds());//long Console.WriteLine("{0} --> Unix Milliseconds_01: {1}", dto01, dto01.ToUnixTimeMilliseconds());//long Pause(); } } } /* 2021/1/22 下午 04:14:49 +08:00 --> Unix Seconds_00: 1611303289 2021/1/22 下午 04:14:49 +08:00 --> Unix Milliseconds_00: 1611303289523 2021/1/22 上午 08:14:49 +00:00 --> Unix Seconds_01: 1611303289 2021/1/22 上午 08:14:49 +00:00 --> Unix Milliseconds_01: 1611303289526 Press any key to continue... */

本文由jashliaoeuwordpress提供 原文連結

寫了 5860316篇文章,獲得 23313次喜歡
精彩推薦