Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Formatter: Date Problem
04/09/2010
02:21
Avatar
miked
Member
Members
Forum Posts: 5
Member Since:
04/09/2010
sp_UserOfflineSmall Offline

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!

04/09/2010
14:19
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

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.

09/09/2010
01:17
Avatar
miked
Member
Members
Forum Posts: 5
Member Since:
04/09/2010
sp_UserOfflineSmall Offline

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).

09/09/2010
02:49
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hi!

Could you post a code example with the test JSON data which could be used to reproduce your problem?

Regards
Oleg 

20/10/2010
00:37
Avatar
miked
Member
Members
Forum Posts: 5
Member Since:
04/09/2010
sp_UserOfflineSmall Offline

FYI....I ended up using your suggestion to pass only numbers.  I am formatting the date on the server side and passing a "m d Y" formated date.  I had issues when trying to pass characters like "/" or "-" too.  Just numbers and spaces works.

Thanks!

27/10/2010
16:00
Avatar
tucano
Rio Grande do Sul - Brasil
Member
Members
Forum Posts: 7
Member Since:
22/10/2010
sp_UserOfflineSmall Offline

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

{name:'TESTANDO_DATA',index:'TESTANDO_DATA', width:100, formatter:'date', formatoptions:{srcformat:"Y-m-d",newformat:"d/m/Y"}}

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

{name:'TESTANDO_DATA',index:'TESTANDO_DATA', width:100, formatter:'date', formatter:'date', formatoptions:{srcformat:"Y-m-d",newformat:"m/Y"}},

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).

{name:'TESTANDO_DATA',index:'TESTANDO_DATA', width:100, formatter:'date',formatoptions:{srcformat:"Y-m-d",newformat:"Y/m/d"}}

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

{name:'TESTANDO_DATA',index:'TESTANDO_DATA', width:100, formatter:'date', formatoptions:{srcformat:"Y-m-d",newformat:"d/m/Y"}}

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

{name:'TESTANDO_DATA',index:'TESTANDO_DATA', width:100, formatter:'date', formatoptions:{srcformat:"Y-m-d",newformat:"m/Y"}}

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).

{name:'TESTANDO_DATA',index:'TESTANDO_DATA', width:100, formatter:'date',formatoptions:{srcformat:"Y-m-d",newformat:"Y/m/d"}}

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

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information