I have a Property
[DataType(DataType.Date)]
public DateTime? DatePost { get; set; }
And I want to format the DateTime for each item of this property.
Select(x => new
{
x.Price,
x.ItemsCount,
x.DatePost});
var result = query.toList();
So I was trying to use a foreach to get each property and change to ShortDateString, but the result of query it always come with the time together. The format has to be like this "dd/MM/yyyy".
List<dynamic> l = new List<dynamic>();
var result = users.ToList();
foreach (var item in result)
{
item.DatePost?.ToShortDateString();
l.Add(item);
}
return Ok(l);
The result is :
2017-04-15T23:53:00.193