Sometimes we need to play with date and we need to display date in reverse format. So I am here with a C# code research.
This example is for today’s date while you can change this code to display any date in reverse format.
Source code Display Date in Reverse Format in C#:
private string ReversedDateString( )
{
string reversedDate;
// year component
reversedDate = DateTime.Now.Year.ToString().Substring( 2, 2 );
// month component
reversedDate += DateTime.Now.Month.ToString( "00" );
// day component
reversedDate += DateTime.Now.Day.ToString( "00" );
return reversedDate;
}
The above program is not working please check out
ReplyDeleteHi,
ReplyDeleteThis is working fine.
like for todays date 7/6/2011
it will print 110607
while if you want year in full format you can the below line
reversedDate = DateTime.Now.Year.ToString().Substring( 2, 2 );
to
reversedDate = DateTime.Now.Year.ToString();
it will print
20110607