-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02-timeLeft2.aspx.cs
40 lines (32 loc) · 1.12 KB
/
02-timeLeft2.aspx.cs
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
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
string msg, days, hours, minutes;
TimeSpan timeSpan;
public void timer()
{
// Set date/time of New Years Day and right now
DateTime rightnow = DateTime.Now;
DateTime newYears = new DateTime(DateTime.Now.Year+1, 1, 1);
// Compute the difference in time/dates
timeSpan = newYears.Subtract(rightnow);
// Compute and display the differences in days, hours, and minutes
days = timeSpan.Days.ToString();
msg = string.Format("Days: {0}, ", days);
Response.Write(msg);
hours = timeSpan.Hours.ToString();
msg = string.Format("Hours: {0}, ", hours);
Response.Write(msg);
minutes = timeSpan.Minutes.ToString();
msg = string.Format("Minutes: {0} <br />", minutes);
Response.Write(msg);
}
}
}