سؤال

I have a webgrid column which returns date and time as ex: "11/29/2013 2:49:56 PM" . I dont want to change my SP but want to show only date in column as "11/29/2013". How is it possible ?

هل كانت مفيدة؟

المحلول

If your model have a datetime item say 'CreatedDate' and you are binding this item with your webgrid column then you can use the below code to format datetime

@item.CreatedDate.ToString("dd/MM/yyy")

نصائح أخرى

If your model doest not have Datetime means use this

DateTime CreatedDate= Convert.ToDateTime(@item.CreatedDate);

Hope it helps

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top