erdcck
Posts: 17
|
Posted: 08/13/2014, 10:20 AM |
|
Dear friends and saseow :)
My customers using our application from different countries. Every customer adding own records. Application have a hidden control for adding current time.
Actually all record time same. because codecharge getting date and time from server. How can I get customer local date and time in hidden control?
thank you so much
|
|
|
saseow
Posts: 744
|
Posted: 08/13/2014, 10:53 AM |
|
The timezone will always be the server's timezone so, you have to change that to the user's timezone.
Have a look at the following and I am sure you can sort it out:
http://www.pontikis.net/tip/?id=18
This is a good example of doing it: http://stackoverflow.com/questions/470617/get-current-date-and-time-in-php
By reading up on it you always learn better than simply having code given. Have fun!
|
|
|
erdcck
Posts: 17
|
Posted: 08/14/2014, 12:19 AM |
|
Dear saseow thank you so much , I did it .
Step one = I created one mysql table, table name zone. and import zone names in table. (zone file csv http://turbobit.net/b2ll3klpzdnh.html)
step two = Add timezone selector (listbox) customers settings page.
step tree = add following custom code for hidden control ( I change hidden properties date to text)
$db = new clsDBxxxDB;
$timezone_name = ccdlookup("timezone_name","companies","company_id=".CCGetSession("company_id",""), $db);
date_default_timezone_set($timezone_name);
$date = date('Y/m/d H:i:s', time());
$jobs1->job_added_date->SetValue($date);
$db->close();
|
|
|
saseow
Posts: 744
|
Posted: 08/14/2014, 1:35 AM |
|
Excellent! That;s the way to go.
|
|
|
erdcck
Posts: 17
|
Posted: 08/14/2014, 2:24 AM |
|
Thank you saseow
I changed globaly timezone. I added following code in Common.php (end line)
$db = new clsDBxxxxDB;
$timezone_name = ccdlookup("timezone_name","companies","company_id=".CCGetSession("company_id",""), $db);
if ($timezone_name <> ""){
date_default_timezone_set($timezone_name);
}
$db->close();
|
|
|
erdcck
Posts: 17
|
Posted: 08/14/2014, 6:37 AM |
|
Dear saseow I have a problem :)
Php timezone settings okay no problem everything fine.
I want to change mysql timezone for customers like a php. How Can I do.
After adding the customer's own record. Not showing in todays records in grid.
Because
mysql timezone = Europe/Istanbul.
php timezone = Pacific/Fiji.
I used following code but not work.
mysql_query("SET time_zone = '".date_default_timezone_get()."';");
I m waiting for your help. thank you.
|
|
|
saseow
Posts: 744
|
Posted: 08/14/2014, 9:03 PM |
|
I do not think that it is possible to do this unless you own the server. However, I am not 100% sure about this.
Have a look at these two pages:
http://stackoverflow.com/questions/13916747/set-mysql-d...timezone-to-gmt
http://stackoverflow.com/questions/3451847/mysql-timezone-change
Sorry, I cannot help with this one.
|
|
|
icp4all
Posts: 37
|
Posted: 08/15/2014, 4:12 PM |
|
Thats just simple (in theory)
You must store all times in a timestamp (Server Time!)
Now you only need the Users local time (must be stored in the user's profile).
I used the PHP function.
And now you can calculate the difference !!!
Everytime a User adds a record, your form retrieves the difference from the user record and store the (user)time in the db...
For all displayed Dates you have to calculate the time in the same way
so IE
user adds a date
before insert - > retrieve User time zone -> Add/subtract the difference and store the (calculated time) to DB
User opens a List, Grid, receive a email or what ever
before Show - > retrieve User time zone -> Add/subtract the difference and store the calculateed time
to the variable in your form
BTW if a user travels from IE from Europe to China.. he just need to change his timezone in his profile and all dates will be shown in the new local (here china time)
hope this helps a little bit...
I made an event planer for an international Gaming clan, and it works fine
but it took 3 or 4 days to manage the problem with ccs
|
|
|
erdcck
Posts: 17
|
Posted: 08/18/2014, 6:49 AM |
|
Dear friends thank you so much for your posts.
I solved the problem.
--------------------------- CHANGE PHP DEFAULT TIME ZONE -- SET TIMEZONE SESSION ------------------------------------
Step one = I created one mysql table, table name zone. and import zone names in table. (zone file csv http://turbobit.net/b2ll3klpzdnh.html)
Step two = Add timezone selector (listbox) customers settings page.
Step tree = add following code to commom.php
$db = new clsDBmyprintDB;
$timezone_name = ccdlookup("timezone_name","companies","company_id=".CCGetSession("company_id",""), $db);
if ($timezone_name <> ""){
date_default_timezone_set($timezone_name);
CCSetSession("TimeZone", "$timezone_name"); // timezone name example 'Pacific/Fiji'
}
$db->close();
---------------------- GET RECORDS SQL QUERY WITH CONVERT_TZ --------------------------------
SELECT *
FROM (jobs INNER JOIN customer ON
jobs.is_customer_id = customer.customer_id) INNER JOIN job_status ON
jobs.is_durumu = job_status.job_status_id
WHERE jobs.company_id = {company_id} AND datediff(is_teslim_tarihi, CONVERT_TZ(NOW(), @@global.time_zone, '{TimeZone}')) between 0 and 0
ORDER BY job_status_id = 5 DESC, customer_id
|
|
|
|