Extjs timefield display normal time format

Source: Internet
Author: User

The date and time formats of JSON returned by the background are often similar to "\/date (1309200300000) \/", and the results cannot be normally displayed in timefield, if you want to display it correctly, the general method is to change the background code to convert the date and time format to string, and the solution is to rewrite the setvalue of timefield. The specific code is as follows:

Ext. override (ext. form. timefield, {getvalue: function () {return this. value;}, setvalue: function (v) {This. value = V; this. setrawvalue (this. formatvalue (v); return this;}, formatvalue: function (v) {If (v. length> 8) {// a maximum of 8 timefields and more than 8 fields must be var jsondate = eval ("new" + v. substr (1, V. length-2 )). tolocaletimestring (); jsondate = jsondate. length = 8? Jsondate. substr (0, 5): '0' + jsondate. substr (0, 4); // tolocaletimestring is relatively retarded. If the returned hour is less than 10 hours, only one return jsondate;} return v ;}});

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.