Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8198421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:56:52+00:00 2026-06-07T05:56:52+00:00

I have a JQGrid that has a date column. I use the date formatter

  • 0

I have a JQGrid that has a date column. I use the date formatter to format the date to a m/d/Y format. Previously, if the format of the source date did not match the srcformat I passed in the formatoptions, it just wouldn’t format the date. JQGrid v4.4.0 now attempts to format the date no matter the source format, and comes up with dates that are wayyy off :-).

The dates I have populating into this column could either be in the correct format already (m/d/Y) or be in the format I have defined in srcformat (Y-m-dTH:i:s).

Is there a way in JQGrid 4.4.0 to not try to parse dates that do not match the srcformat?


My colModel def for column:

{name:"date", index:"date", label:"Date", width:85, jsonmap:"date", hidden: false, formatter:'date', sorttype: 'date', formatoptions:{srcformat:'Y-m-dTH:i:s', newformat:'m/d/Y'}, searchrules: { date: true } }        
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:56:53+00:00Added an answer on June 7, 2026 at 5:56 am

    I solved my own issue 🙂

    I created a custom formatter and used the Datejs JQuery library to help out in parsing the date.

    Basically the formatter only formats the date to m/d/Y format if it is in the Y-m-dTH:i:s format; otherwise, it assumes it’s already in the m/d/Y format and leaves it be.

    /**
     * This function formats the date column for the summary grid.
     * 
     * The grid could be populated with dates that are in m/d/Y format or in Y-m-dTH:i:s format; need
     * to account for this; want the dates to end up being in m/d/Y format always.
     * 
     * @param cellvalue     is the value to be formatted
     * @param options       an object containing the following element
     *                      options : { rowId: rid, colModel: cm} where rowId - is the id of the row colModel is the object of the properties for this column getted from colModel array of jqGrid
     * @param rowObject     is a row data represented in the format determined from datatype option;
     *                      the rowObject is array, provided according to the rules from jsonReader
     * @return              the new formatted cell value html
     */
    function summaryGridDateFormatter(cellvalue, options, rowObject) {
    
        // parseExact just returns 'null' if the date you are trying to 
        // format is not in the exact format specified
        var parsedDate = Date.parseExact(cellvalue, "yyyy-MM-ddTHH:mm:ss"); 
    
        // if parsed date is null, just used the passed cell value; otherwise, 
        // transform the date to desired format
        var formattedDate = parsedDate ? parsedDate.toString("MM/dd/yyyy") : cellvalue;
    
        return formattedDate;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a load once jqgrid that uses a custom formatter to display checkboxes
I have a jqgrid, where it has a custom formatter to column1. I need
I have a jqGrid that has add/edit dialogs with a form that's longer than
I have a jqgrid that has a subgrid. How can I expand the subgrid
I have a jqgrid in a modal popup that has data dependent on some
In my jqgrid, I have a cell that has link in it.Currently when the
I have a page, that has jqgrid, it is fetching json from a url.
I have jqgrid that has 23 headers. It has edit dialog with a form
I have a jqgrid that contains some data, the first column of which is
I have a JQGrid that has the custom setup fro editing and saving row

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.