Forum


02:21

04/09/2010

Hi,
I have a grid that uses json to get data from ColdFusion. I am having trouble formatting a date field. Here is my ColModel string:
{name:'DISPLAYSTOP',index:'displayStop', width:150, formatter:'date', formatoptions:{srcformat:"F, d Y H:i:s",newformat:"d-F-Y H:i:s"}},
I can see (in Firebug) that the date field passed to the grid is this: March, 26 2010 23:59:00
However, the display is this: 26-January-2010 23:59:00
In fact, all the months get displayed as January. The day, year, hour, minute, and seconds get read and displayed correctly, but the month is displayed as January for all records. I have tried all the PHP date codes (F,M,m,n) for months and tried without the comma, but nothing works.
If I use M instead of F in the newformat (newformat:'d-M-Y H:i:s), all the months return as Jan.
If I remove formatter:'date' from the ColModel, it displays the same as the input: March, 26 2010 23:59:00
Any ideas?
Thanks!
14:19

10/08/2009

I recommend you use only numbers as a month if you send data back from the server. You will transfer less data from the server and the data will be language independent.
Because of your main problem. It seems to me that in the line 170 of jquery.fmatter.js (I use 3.8 beta so line number could be a little other in another version of jqGrid) there are a bug. Currently the line is
F: dateFormat.i18n.monthNames[n - 1 + 12],
It seems to me the correct line should be
F: dateFormat.i18n.monthNames[n - 1],
Format for "M" is correct, so if you use minimized version of jqGrid you can try with newformat:"d-M-Y H:i:s".
Best regards
Oleg
P.S. I hope Tony will fix the bug.
01:17

04/09/2010

Thanks for the input Oleg, but the problem still exists. If I make the correction you note above and change the line to:
F: dateFormat.i18n.monthNames[n - 1],
It displays "Jan" instead of "January". But my problem is that the date is always displayed as Jan or January instead of the actual month. So all dates submitted, whether they are March or May or September or any date all get displayed as January. If I submit the date 04/22/2010, it will be displayed in the grid as (d-M-Y formatted) 22-Jan-2010.
The day and year are read correctly, but the month is always January (or Jan, or 1). It's like the month is not being read and it defaults to the first item on the list (Jan).
16:00

22/10/2010

Olá,
estou tendo problemas referente ao formatter também,
embora minha lista é datatype:"local", estou passando pela mesma questão.
eu tenho a intenção de formatar um campo do tipo data em d/m/Y com uma entrada Y-m-d, mas obtenho resultados absurdos
exemplo 1:
entrada: 2010-10-13
saída formatada obtida: 02/04/2019
exemplo 2:
entrada: 2010-09-10
saída formatada obtida: 02/03/2016
com finalidade de teste modifiquei a formatação desejada na saída com intenção de apenas visualizar o mês e o ano (m/y), mas obtive resultados mais estranhos ainda
exemplo 1:
entrada: 2010-10-13
saída formatada obtida: 06/2177
exemplo 2:
entrada: 2010-09-10
saída formatada obtida: 06/2176
contudo, concluindo os testes percebi que deve ter algum bug neste processo, pois se eu não tentar intervir na ordem de dia, mês e ano da referente data, o processo de formatação funciona devidamente correto (claro, para meu problema inicial não resolve).
exemplo 1:
entrada: 2010-10-13
saída formatada obtida: 2010/10/13
exemplo 2:
entrada: 2010-09-10
saída formatada obtida: 2010/09/10
Caso alguém tiver a solução para essa questão, desde já agradeço.
Fico também a disposição para qualquer eventual teste referente a esta questão.
Até mais!
atenciosamente,
Tucano
------------------------------------------------------------------------------------------
Mensagem traduzida do Português-Brasil para o Inglês pelo google translate
Message translated from Portuguese-Brazil to the English translation by google
------------------------------------------------------------------------------------------
Hello,
I'm having trouble referring to the formatter also
although my list is datatype: "local", I am experiencing the same issue.
I intend to format a field of type date d / m / Y with an entry Ymd, but get absurd results
Example 1:
Login: 2010-10-13
formatted output achieved: 02/04/2019
Example 2:
Login: 2010-09-10
formatted output achieved: 02/03/2016
with the purpose of testing the modified desired output format with the intention of just display month and year (m / y), but getting even weirder results
Example 1:
Login: 2010-10-13
formatted output obtained: 06/2177
Example 2:
Login: 09/10/2010
formatted output obtained: 06/2176
however, ending the testing should have realized that a bug in this process, because if I did not try to intervene in the order of days, months and years regarding the date, the process of properly formatting works correctly (of course, for my initial problem does not solve).
Example 1:
Login: 2010-10-13
formatted output achieved: 2010/10/13
Example 2:
Login: 09/10/2010
formatted output achieved: 2010/09/10
If anyone has a solution to this question, I thank you.
I am also available for any possible test for this question.
Goodbye!
Sincerely,
Tucano
att,nTucano
Most Users Ever Online: 715
Currently Online:
41 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66