in dot net frame work 2
how to better this and easy to used i have many times
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string timenow = DateTime.Now.ToString("T");
Label1.Text = DateTime.Now.ToString("T");
Label3.Text = DateTime.Now.ToString("D");
Label2.Text = getTimeZone(timenow);
}
//hh:mm:ss
protected string getTimeZone(string time)
{
string[] e = time.Split(':');
int h = Convert.ToInt16(e[0]);
int m = Convert.ToInt16(e[1]);
int s = Convert.ToInt16(e[2]);
if ((h == 15) && (m >= 1) && (m <= 30) && (s <= 59))
{
return "15.01 - 15.30";
}
if ((h == 15) && (m >= 31) && (m <= 45) && (s <= 59))
{
return "15.31 - 15.45";
}
if ((h == 15) && (m >= 46) && (m == 0) && (s <= 59))
{
return "15.31 - 15.45";
}
return time;
}
}