13 November 2013

Different Date&Time Formats using in C#.NET and ASP.NET


2.Different Date&Time Formats Using in C#.NET 

and ASP.NET

-> Open Visual Studio

-> Click on New Project and add a one page(.CS / .aspx) in Solution Explorer

-> In " Form1.cs "page,Drag and Drop the few Label controls from ToolBox.

-> then write the Code for that page as shown below........


Using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class CurrentDate : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = System.DateTime.Now.ToString();

Label3.Text = System.DateTime.Now.ToLongDateString();

Label4.Text = System.DateTime.Now.ToLongTimeString();

Label5.Text = System.DateTime.Now.ToShortDateString();

Label6.Text = System.DateTime.Now.ToShortTimeString();

}
}

-> then Compile and Run.then Displays Result as shown below....



No comments:

Post a Comment