Only recently began to use Easyui and Mvc4 to do the project, to jquery what is completely unfamiliar, the DataGrid in the resolution of the JSON conversion date format problem, there is a new problem, the date in the table becomes such
XX date
2015-3-1 00:00:00
It seems that the user experience is very poor, before the Web form the time is quite good to change this, but now do not know, until just saw someone's article, only to find the method not too simple,
There are fomatter methods in the DataGrid that can be written like this
{field: ' Vehicleinspectiondate ', Title: ' Assurance Validity ', width:80, Sortable:true, formatter:function (value, row, index) { var unixtimestamp = new Date (value); return unixtimestamp.tolocaledatestring (); }},
The original new date can not only take the time of course, but also can pass value up, not only can pass value, also can format,
Yes
- toDateString ()-Displays the day of the week, months, days, and years in an implementation-specific format;
- toTimeString ()-Displays hours, minutes, seconds, and time zones in an implementation-specific format;
- toLocaleDateString ()-Displays hours, minutes, seconds, and time zones in an implementation-specific format;
- toLocaleTimeString ()-Displays the time, minutes, and seconds in an implementation-specific format;
- toUTCString ()--Displays the full UTC date in an implementation-specific format.
There are a number of ways you can point out many of the formats you want, such as todatestring (), which is the YYYY-MM-DD format.
toLocaleDateString () shows the yyyy mm month DD Day
--------
It is convenient indeed.
Easyui in the DataGrid time format (only displays the date of year and month)