[note] Formatting the date and time in the Jqgrid, resolving hours and seconds are displayed as 0

Source: Internet
Author: User
Tags time and seconds jqgrid

A column in a Jqgrid list page in the project needs to display the date and time, for example: 2011-08-10 10:20:30, check the official wiki documentation for instructions and examples, and then in Colmodel the formatter of the column that needs to format the time: ' Date ' After adding some formatoptions configuration, but IE and FF browser has no effect, there is no hint of error ~

Helpless official Wiki Document date time format part of the description and examples for me is not fine enough, had to see jquery.fmatter.js in the source code of the DateFormat part, fortunately found out, The original Srcformat and Newformat values can be used in the masks of those options, and masks just have the date and time format I need--iso8601long: "Y-m-d h:i:s". Ha, this is good, immediately after formatter: ' Date ' write on Formatoptions:{newformat: ' Y-m-d h:i:s '} and save and then empty the cache of IE and FF browser again to access ~

Strange, now the data format is in line with the requirements, but the time and seconds are displayed as 0, debugging the background data, found that the date transmitted over the time part of the data is not 0!!! Is it the effect of Jqgrid default date formatting configuration? Then look at the grid.locale-zh_cn.js in the date format section of the configuration, sure enough is srcformat: ' y-m-d ' Ah! This is why I set the Formatoptions:{newformat: ' y-m-d h:i:s ' after the display of the time division seconds part of the value is 0, originally is not formatted in the source datetime format seconds (h:i:s) part, Then the new formatted time will default to the source formatting portion of the seconds set to 0!

Haha, then the formatter: ' Date ' of the Formatoptions configuration from Formatoptions:{newformat: ' y-m-d h:i:s '} to Formatoptions:{srcformat: ' Y-m-d h:i:s ', Newformat: ' y-m-d h:i:s '} and save, and then empty the Internet Explorer and FF browser cache re-access, haha, both browsers are OK!

[Moved from Blogbus]

[note] Formatting the date and time in the Jqgrid, resolving hours and seconds are displayed as 0

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.