!!!現在の日時を取得 日時の取得は「System.DateTime」クラスを使用します。以下のようにすると、現在の日時情報を取得します。 System.DateTime nowDT = System.DateTime.Now; int year = nowDT.Year; // 西暦の年. int month = nowDT.Month; // 月. int day = nowDT.Day; // 日. int hour = nowDT.Hour; // 時 (24時間表記). int minute = nowDT.Minute; // 分. int second = nowDT.Second; // 秒. また、 string datetimeStr = System.DateTime.Now.ToString(); とすることで、string型の日時文字列が取得できます。 4/10/2014 8:20:45 PM のように返されます。 !!経過時間を取得 経過時間は「System.TimeSpan」クラスを使用します。 System.DateTime oldDate = new System.DateTime(2000,1,1, 0, 0, 0); // 2000年1月1日、00:00:00. System.DateTime nowDate = System.DateTime.Now; // 現在の日時. System.TimeSpan ts = nowDate- oldDate; double totalSec = ts.TotalSeconds; // 経過秒数. double totalHours = ts.TotalHours; // 経過時間. double totalDays = ts.TotalDays; // 経過日数. 取得したtotalDaysに24をかけるとtotalHoursになります。 totalHoursに60 * 60をかけるとtotalSecになります。 ---- {{lastmodified}}