...the way I did that - learning through examples...

воскресенье, 17 января 2010 г.

DateTime sample




If you want to display current date or time on the website you can use DateTime.Now property.
This sample shows how to display it using 5 different formats.

protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.DayOfWeek.ToString();//return the current day of week
Label2.Text = DateTime.Now.ToLongDateString(); //return the "long date"
Label3.Text = DateTime.Now.ToShortDateString(); //return the "short date"
Label4.Text = DateTime.Now.ToLongTimeString(); //return the "long time"
Label5.Text = DateTime.Now.ToShortTimeString(); //return the "short time"

}

All our simple samples available as Microsoft Visual Studio 2008 website projects.
You can DOWNLOAD this DateTime sample project from Rapidshare.

Комментариев нет:

Отправить комментарий