Display date as per client timezone

QuestionsDisplay date as per client timezone
Sunil asked 8 years ago

Hi Abu,
We have clients spread across the globe,
We are saving the grid data in UTC time zone now
How can I display the data with the timezone of the client in the grid.

I need to convert the date which is in UTC to the client's timezone.
Can I do something with this function

col["on_data_display"] = array("Function","");

Thanks

4 Answers
Abu Ghufran answered 8 years ago

This is something that is outside the scope of phpgrid.

I would recommend to following stackoverflow solutions. 1) cookie based 2) maxmind geoip based.
http://www.google.com/search?q=php+client+timezone

Sunil answered 8 years ago

Hi,
Thanks for the reply.
Let me re-frame my question, Is there a way to display data saved in UTC as UTC+ 5:30 in the grid?
I save my data in UTC, I need to convert it to timezone of the client(I know which timezone My clinets are in) and display it in the grid

Abu Ghufran answered 8 years ago

I think this function will do your work UTC to local.

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_convert-tz

// you can provide custom SQL query to display data
$g->select_command = "SELECT i.id, CONVERT_TZ(invdate,'+00:00','+5:30') as invdate , c.name,
i.note, i.total, i.closed FROM invheader i
INNER JOIN clients c ON c.client_id = i.client_id";

To save data back in UTC, you may need to use on_insert / on_update function.

dewaz answered 7 years ago

is it ..
$col["on_data_display"] = array("display_keyword","");

only works for paid version?

Your Answer

8 + 3 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?