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