Search code examples
jqgridjqgrid-formatter

jqgrid date not displaying correctly


Using JQGrid 4.6.0

SQL Server using a date field to hold the meeting date. NO TIME.

enter image description here

Using this code block (note the formatter) - with the value of datetime

enter image description here

This is the resulting output

enter image description here

The date field shows the correct date, in the correct format - EXCEPT the timestamp is being displayed.

Now using date only in the formatter

enter image description here

This is the output i am receiving

enter image description here

Two things to look at - one, the timestamp is gone - yeah! BUT the dates are WAAAYYY off.

What i am looking for is to display the date as it comes from the date field in the database, using the customer accepted format of (m/d/Y - 12/31/2014)

Am i missing something?


Solution

  • A bit late, but can be useful for future searchers.

    To display correct date:

    • On server - Return dateTime in correct format, json example:

      "dateTime":"2016-01-19T19:12:42.93"

    • On Client - Use this column configuration

      sorttype: 'date', formatter: 'date', formatoptions: { srcformat:'ISO8601Long', newformat: 'm.d.Y'}

    This configurations allows to display correct date and this column will have correct sorting.

    Note: jqGrid dosn't have datetime formater, see this answer