jQuery UI Widgets › Forums › Grid › Definitive way to show date with time (as it comes from the server) in the grid?
Tagged: #jqwidgets-grid, angular grid, angular2 grid, bootstrap grid, javascript grid, jquery grid, jqxGrid ;, typescript grid
This topic contains 17 replies, has 4 voices, and was last updated by Singh_kiatec 3 years, 11 months ago.
-
Author
-
January 17, 2017 at 11:43 pm Definitive way to show date with time (as it comes from the server) in the grid? #90752
There have been numerous threads about this and even JSFiddles, yet none have a definitive example on how to do this. How can you show the date (with time) in the grid WITHOUT it subtracting (or adding) the hours for the timezone?
Here is a fiddle to show you an example : http://jsfiddle.net/sGGZ3/568/
It uses this as a sample date from the ‘server’…
var data = '[{"date": "2017-01-16T10:38:00.000"}]';
Formatting is..
{ text: 'date', datafield: 'date', cellsformat: 'yyyy-MM-dd HH:mm:ss' }
Yet it still shows “2017-01-16 03:38:00” which is the server date minus the 7 hours for my timezone : http://i.imgur.com/VhgVIZ4.png
There has to be some way to have it show “2017-01-16 10:30:00” as a date (not a rendered string because sorting needs to work as a date).
January 18, 2017 at 9:34 am Definitive way to show date with time (as it comes from the server) in the grid? #90766Hello lucasgraf,
You should set the desired format in the source.
Please, take a look at this example:
datafields: [{ name: 'date', type: 'date', format: "yyyy-MM-ddTHH:mm:ss.fff" }]
Hope this helps.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comJanuary 18, 2017 at 10:25 pm Definitive way to show date with time (as it comes from the server) in the grid? #90790OMG! Thank you. That works, w/the caveat that your date string from the server side matches that format you put in the datafield.
July 27, 2017 at 6:37 pm Definitive way to show date with time (as it comes from the server) in the grid? #95179Hi,
I have the date string as ’07/26/2017 03:38 PM EDT’ and I have set the type as ‘date’ and the cellsformat as ‘MM/dd/yyyy hh:mm tt zzz’. However, its still converting the date to my machine’s timezone. I would like to see the date displayed in the same format and timezone in the grid as ’07/26/2017 03:38 PM EDT’. Is the format that I have set correct?
Here’s the fiddle,
http://jsfiddle.net/sGGZ3/607/Thanks,
ShakeelJuly 27, 2017 at 7:20 pm Definitive way to show date with time (as it comes from the server) in the grid? #95180To add to the above issue, I have also set the format in the datafield as the same format ‘MM/dd/yyyy hh:mm tt zzz’.
July 31, 2017 at 2:33 pm Definitive way to show date with time (as it comes from the server) in the grid? #95226Hello shakeel,
You should set received format data in the DataAdapter’s source:
var source = { datatype: "json", datafields: [ { name: 'date', type: 'date', format: 'MM/dd/yyyy hh:mm tt zzz' } ], localdata: data };
Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comJuly 31, 2017 at 3:08 pm Definitive way to show date with time (as it comes from the server) in the grid? #95230Thanks for your response. However, as I commented before, I have already set the format in the datafield(same as what you also suggested) but I still see the date conversion happening. Please have a look at this updated jsfiddle,
http://jsfiddle.net/sGGZ3/608/
so basically, my date input, cellsformat and format are all in the same format and I would like the same to be displayed on the grid.August 1, 2017 at 11:08 am Definitive way to show date with time (as it comes from the server) in the grid? #95247Hello shakeel,
I would like to suggest you use
cellsrenderer
callback for custom visualization with combination.formatDate()
a method of the jqxDataAdapter.
Please, take a look at this example.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comAugust 1, 2017 at 9:26 pm Definitive way to show date with time (as it comes from the server) in the grid? #95253Hi Hristo,
The fiddle shared by you still converts the date/time to local timezone. My requirement is to avoid this and show the date in the same timezone as I receive it.Thanks,
ShakeelAugust 2, 2017 at 10:07 am Definitive way to show date with time (as it comes from the server) in the grid? #95269Hello Shakeel,
You could achieve this on that way, demonstrated in my previous post.
Thecellsrenderer
callback could be used to set the context in the desired way. You could use an array of all time formats and just add this one that is relevant to specific case (EDT, FLE, and etc.)
Also, if you do not need to operate with this data from that column of type ‘date’ you could set it intype: 'string'
and it will be set in this format.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comAugust 2, 2017 at 8:07 pm Definitive way to show date with time (as it comes from the server) in the grid? #95285Yes, I tried setting the type as ‘string’ but that breaks the sort on that column. If I set it to ‘date’ then I face the issue we discussed above.
October 29, 2020 at 12:51 pm Definitive way to show date with time (as it comes from the server) in the grid? #113472Hi Hristo,
I have the same issue , as we have a date i.e 2020-10-27 and it is displayed in GRID 27-10-2020 as expected . But now my team mate see it as 26-10-2020 from his machine as his system timezone is Los Angeles, CA, USA* PDT (UTC -7) .
And i could reproduce it from the above jsfiddle below is the url of the screen shot for reference. I tried all possible ways as mentioned above.
Am i missing anything?
Thanks in advance.
October 29, 2020 at 1:30 pm Definitive way to show date with time (as it comes from the server) in the grid? #113477Hello Singh_kiatec,
You need to use the specific formatting symbol with the
T
symbol.
As I understand you the returned data from the server should be the same without parsing to the time zone.
Please, take a look at this example:
http://jsfiddle.net/txhi/y8zdf1ra/
Also, we have similar forum topics from the past, please, take a look at this one below, it could be helpful:
https://www.jqwidgets.com/community/topic/forma-date-by-time-zone/Best Regards,
Hristo HristovjQWidgets team
https://www.jqwidgets.comNovember 2, 2020 at 2:10 pm Definitive way to show date with time (as it comes from the server) in the grid? #113493Hi Hristo Hristov,
Thanks for the quick response.
Yes thats true. i am trying to achieve to show the same date as received from the server.
Now it works and shows the same date as received from the server . But it now makes filtertype ‘range’ disappear.
I have used the
cellsformat:’dd-MM-yyyy HH:mm:ss’,
filtertype:’range’,Thanks in advance.
November 3, 2020 at 10:17 am Definitive way to show date with time (as it comes from the server) in the grid? #113497Hello Singh_kiatec,
I tested this example below and it seems to work fine:
http://jsfiddle.net/txhi/3Lo12zj9/Best Regards,
Hristo HristovjQWidgets team
https://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.