jQuery UI Widgets › Forums › Grid › jqxGrid date formating
Tagged: date, dd.mm.yyyy, format, jqxgrid, local time
This topic contains 20 replies, has 4 voices, and was last updated by jgarcias 8 years, 10 months ago.
-
AuthorjqxGrid date formating Posts
-
Hi Emre,
The Grid works with JavaScript Date Objects. If you don’t pass TimeZone information to the JavaScript Date object’s constructor, it will Parse your Date to a Local TimeZone and as far as I know, you cannot prevent this.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comAdditional info:
When you create a new date, without specifying a time zone, Javascript will create the date using the browser’s timezone. When you output a date, unless you specifically use UTC date methods, the date will be converted to the user’s local timezone regardless of how the date was created. For instance if you created a date in the Eastern timezone, the date/time will be converted to pacific time if that is where the user resides
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comDear Peter,
My data looks like this: “2014-06-06T15:47:25Z”. I think if I find a way to delete “Z” at the end of the data, problem can be solved. Have you any other suggestion?Emre
Hi Peter,
I found a method in my code that adds “Z” to end of the data when formatting DateTime values. I changed it, and problem solved.Thanks for help.
Best Regards,
EmreHi Emre,
As far as I see your Date String is in UTC format. When you output it, it would be in your Local Time Zone and that’s where the difference comes. One option is to use a more full format so your users would know in which time zone they see the date or you can display the time zone somewhere else on your app, but the Dates are correct. You can also try this: set the data field’s type property to “date” and format property to “yyyy-MM-dd HH:mm:ss”.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi all
I used to have the same problem that SkippingAdi (Adrian) had and I solved it by changing the way I retrieved the data from the database. Before I used to have something like:
SELECT CONVERT(date, myDateColumn) FROM ...
and with this approach jqxGrid used to show something like “Mon May 23 02:00:00 UTC+0200 1988” in my web application regardless of the format that I put in the field in both the source structure and grid column definition.
So, I decided to change that statement for this one:SELECT CONVERT(varchar, myDateColumn, 105) FROM ...
because I needed to show the date with the Italian format (dd-mm-yyyy).
I did not need to make any calculation with that date, it was only an informational date for the user and that’s why I decided to retrieve my data in this way.Hope this helps someone else.
-
AuthorPosts
You must be logged in to reply to this topic.