728x90
반응형
시간 구하기 ticks DateTime Now TimeSpan
@ 시간 구하기 ticks DateTime Now TimeSpan
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | using System; using System.Windows.Forms; namespace WindowsFormsApp1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { DateTime centuryBegin = new DateTime(2001, 1, 1); DateTime currentDate = DateTime.Now; long elapsedTicks = currentDate.Ticks - centuryBegin.Ticks; TimeSpan elapsedSpan = new TimeSpan(elapsedTicks); string msg = currentDate.ToString() + " : currentDate" + "\n" + "총 " + elapsedTicks + " Ticks" + "\n" + "총 " + elapsedSpan.TotalSeconds + " 초" + "\n" + "총 " + elapsedSpan.TotalMinutes + " 분" + "\n" + "총 " + elapsedSpan.TotalMinutes / 60 + " 시간" + "\n" + "총 " + elapsedSpan.TotalMinutes / 60 / 24 + " 일" + "\n" + "총 " + elapsedSpan.Days + "일 " + elapsedSpan.Hours + "시 " + elapsedSpan.Minutes + "분 " + elapsedSpan.Seconds + "초"; richTBox1.Text = msg; } } } | cs |
728x90
반응형