worker Posted October 8, 2009 Posted October 8, 2009 How do I change the time stamp on the sent emails from oscommerce? The hosting is in a different zone than the store.
germ Posted October 8, 2009 Posted October 8, 2009 Server Timezone Fix If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
worker Posted October 9, 2009 Author Posted October 9, 2009 Is there no easier method? I tried changing in the english.php page: @setlocale(LC_TIME, 'en_US.ISO_8859-1'); to @setlocale(LC_TIME, 'en_CA.ISO_8859-1'); That got me within one hour difference. I'm no timezone wiz. How can I make the time go one hour different now without having to edit the coding on a few pages like the suggest patch. The problem is the emails that are sent from oscommerce to the site admin and client have the wrong time (now 1 hour off). Server Timezone Fix
♥ecartz Posted October 11, 2009 Posted October 11, 2009 There is a bug in the contribution. You (and contributions in general) should not edit the configure.php files to do this. Since you are only using the offset in the database files, you might as well hard code it. From the contribution, with edits: 1. in the file /catalog/includes/languages/english.php add the following only if it is NOT already present :- putenv("TZ=Australia/Sydney"); // this is for Sydney Australia. Set TZ= to the correct values for your location @setlocale(LC_TIME, 'en_AU.ISO_8859-1'); 2. in the file /catalog/admin/includes/languages/english.php add the following only if it is NOT already present :- putenv("TZ=Australia/Sydney"); // this is for Sydney Australia. Set TZ= to the correct values for your location @setlocale(LC_TIME, 'en_AU.ISO_8859-1'); 3. in the file /catalog/includes/functions/database.php find the code :- function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') { global $$link; if (USE_PCONNECT == 'true') { $$link = mysql_pconnect($server, $username, $password); } else { $$link = mysql_connect($server, $username, $password); } if ($$link) mysql_select_db($database); return $$link; } and replace with the following code :- function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') { global $$link; if (USE_PCONNECT == 'true') { $$link = mysql_pconnect($server, $username, $password); } else { $$link = mysql_connect($server, $username, $password); } if ($$link) { mysql_select_db($database); tep_db_query('SET time_zone=\'+10:00\''); } return $$link; } 4. in the file /catalog/admin/includes/functions/database.php find the code :- function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') { global $$link; if (USE_PCONNECT == 'true') { $$link = mysql_pconnect($server, $username, $password); } else { $$link = mysql_connect($server, $username, $password); } if ($$link) mysql_select_db($database); return $$link; } and replace with the following code :- function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') { global $$link; if (USE_PCONNECT == 'true') { $$link = mysql_pconnect($server, $username, $password); } else { $$link = mysql_connect($server, $username, $password); } if ($$link) { mysql_select_db($database); tep_db_query('SET time_zone=\'+10:00\''); } return $$link; } That's six edits (two lines changed; four lines added) to four files -- I don't see you being able to improve upon that. You could probably fix your issue by making just one of the edits, but that would still leave the time inconsistent in other places. Note that the four files cover catalog and admin for PHP and database. I'm not convinced that it is correct to set the DB timezone -- it would be better IMO to have the DB timezone in UTC and then modify it when used (which would allow for multiple zones for a single cart, where this only allows for a single timezone for all locales). However, osCommerce is not set up to do that and I suspect that many databases do not default to UTC (because they use the locale specific value that works for the majority of their clients instead). This is the simplest way to make the change, if not the most correct. Note that in Canada, the offset would range from -3:30 (e.g. in St. John's) to -8:00 (e.g. in Vancouver) where this has +10:00 and the env setting would be something like America/Toronto (-5:00). I'd have tried editing the instructions, but you don't say where you actually are. It might actually be better to set the database timezone to something like America/Toronto rather than use the offset, but that could be hard to get right. If you can do SELECT * FROM mysql.time_zone_name; on your host, you could at least get the list of valid time zone names. Always back up before making changes.
worker Posted October 19, 2009 Author Posted October 19, 2009 Thanks for the information and help. I did what you have below, but the time is still off. The store is located in Brantford Ontario Canada. Here is what I put: putenv("TZ=America/toronto"); // Set TZ= to the correct values for your location @setlocale(LC_TIME, 'en_US.ISO_8859-1'); Some Questions: 1. Am I to use "America/Toronto (-5:00)" instead of "TZ=America/toronto" in the english.php files? 2. What LC-Time is needed? 3. Do I still need to install the timezone fix: http://addons.oscommerce.com/info/5432 or are the coding edits shown essentially the addon? Time shows There is a bug in the contribution. You (and contributions in general) should not edit the configure.php files to do this. Since you are only using the offset in the database files, you might as well hard code it. From the contribution, with edits: 1. in the file /catalog/includes/languages/english.php add the following only if it is NOT already present :- putenv("TZ=Australia/Sydney"); // this is for Sydney Australia. Set TZ= to the correct values for your location @setlocale(LC_TIME, 'en_AU.ISO_8859-1'); 2. in the file /catalog/admin/includes/languages/english.php add the following only if it is NOT already present :- putenv("TZ=Australia/Sydney"); // this is for Sydney Australia. Set TZ= to the correct values for your location @setlocale(LC_TIME, 'en_AU.ISO_8859-1'); 3. in the file /catalog/includes/functions/database.php find the code :- function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') { global $$link; if (USE_PCONNECT == 'true') { $$link = mysql_pconnect($server, $username, $password); } else { $$link = mysql_connect($server, $username, $password); } if ($$link) mysql_select_db($database); return $$link; } and replace with the following code :- function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') { global $$link; if (USE_PCONNECT == 'true') { $$link = mysql_pconnect($server, $username, $password); } else { $$link = mysql_connect($server, $username, $password); } if ($$link) { mysql_select_db($database); tep_db_query('SET time_zone=\'+10:00\''); } return $$link; } 4. in the file /catalog/admin/includes/functions/database.php find the code :- function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') { global $$link; if (USE_PCONNECT == 'true') { $$link = mysql_pconnect($server, $username, $password); } else { $$link = mysql_connect($server, $username, $password); } if ($$link) mysql_select_db($database); return $$link; } and replace with the following code :- function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') { global $$link; if (USE_PCONNECT == 'true') { $$link = mysql_pconnect($server, $username, $password); } else { $$link = mysql_connect($server, $username, $password); } if ($$link) { mysql_select_db($database); tep_db_query('SET time_zone=\'+10:00\''); } return $$link; } That's six edits (two lines changed; four lines added) to four files -- I don't see you being able to improve upon that. You could probably fix your issue by making just one of the edits, but that would still leave the time inconsistent in other places. Note that the four files cover catalog and admin for PHP and database. I'm not convinced that it is correct to set the DB timezone -- it would be better IMO to have the DB timezone in UTC and then modify it when used (which would allow for multiple zones for a single cart, where this only allows for a single timezone for all locales). However, osCommerce is not set up to do that and I suspect that many databases do not default to UTC (because they use the locale specific value that works for the majority of their clients instead). This is the simplest way to make the change, if not the most correct. Note that in Canada, the offset would range from -3:30 (e.g. in St. John's) to -8:00 (e.g. in Vancouver) where this has +10:00 and the env setting would be something like America/Toronto (-5:00). I'd have tried editing the instructions, but you don't say where you actually are. It might actually be better to set the database timezone to something like America/Toronto rather than use the offset, but that could be hard to get right. If you can do SELECT * FROM mysql.time_zone_name; on your host, you could at least get the list of valid time zone names.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.