CSharp examples for System:DateTime Day
This method returns a two digit day for the date given.
using System.IO;// w ww . j a va2 s .c om using System.Text; using System.Linq; using System.Collections.Generic; using System; public class Main{ #endregion #region GetTwoDigitDay(DateTime date) /// <summary> /// This method returns a two digit day for the date given. /// </summary> /// <param name="date"></param> /// <returns></returns> public static string GetTwoDigitDay(DateTime date) { // initial value string twoDigitDay = ""; // set the twoDigitDay twoDigitDay = date.Day.ToString(); // if the Length is less than two if (twoDigitDay.Length < 2) { // prepend a zero to the Day twoDigitDay = "0" + date.Day.ToString(); } // return value return twoDigitDay; } }