In c# we need to convert datetime in different formats.In this post we will see how to get datetime in "dd/mm/yyyy" format.To parse datetime in "dd/mm/yyyy" format we need to use string formatter "dd/mm/yyyy" in .ToString() constructor.
Code to get datetime in dd/mm/yyyy format [C#]
using System;
public class StringToDateTime
{
public static void Main()
{
var myDateTimeValue = "2012-01-16 15:02:26";
DateTime myDateTime = DateTime.Parse(myDateTimeValue);
var dateingddmmyy = myDateTime.ToString("dd/mm/yyyy");
Console.Write(dateingddmmyy);
}
}
0 Comments :
Post a Comment