Easyui in the DataGrid time format (only displays the date of year and month)

Source: Internet
Author: User
Tags time zones

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.