This article will help you to change the display format of a DateTime variable in C#.NET. As you all know that DateTime variable is used to store date and time of any particular. and some time we need to change the format of this value. For Example some time we need to display only Date or only Time from the DateTime value. Also some time we need to change the format like DD:MM:YY or MM:DD:YY or anyone else. In this project we are using a calender control and we will learn how to change the format according to our requirement.
Free Download: Date Format : Demo Project
Code of Web Page
protected void btngetdate_Click(object sender, EventArgs e) { DateTime dt = Calendar1.SelectedDate; string str = dt.ToString("dd:MM:yyyy"); txtDate.Text = str; }
