Triet Doan
Triet Doan

Reputation: 12085

Cannot format date in jqGrid

here is my situation. From the server (written in C#), I pass a DateTime object to client using JSON, then I try to display it using jqGrid. However, the date keep displaying like /Date(1430413200000+0700)/. I want it to be m/d/Y. Here is my code:

            colModel: [
                {
                    name: 'MyDate',
                    index: 'MyDate',
                    formatter: 'date',
                    formatoptions: {
                        srcformat: "ISO8601Long",
                        newformat: "m/d/Y h:i A"
                    }
                }
            ]

Thank you for your help!

Upvotes: 0

Views: 571

Answers (1)

dreamingblackcat
dreamingblackcat

Reputation: 991

Try adding actual ISO8601Long format like this

 colModel: [
            {
                name: 'MyDate',
                index: 'MyDate',
                formatter: 'date',
                formatoptions: {
                    srcformat: "'Y-m-d H:i:s",
                    newformat: "m/d/Y h:i A"
                }
            }
        ]

Upvotes: 1

Related Questions