eureka Posted January 30, 2003 Share Posted January 30, 2003 The following enables you to set a local time different to your hosts server. Particularly useful if your site is hosted in a different timezone to you and your customers. Adds the necessary number of hours to GMT. Step 1. Add the following to ../catalog/includes/application_top.php & ../admin/includes/application_top.php define ('TIME', strtotime(gmstrftime("%Y-%m-%d %H:%M:%S", strtotime ("+ 11 hour")))); define ('NOW', gmdate ('Y-m-d H:i:s', time() + 11 *3600)); Step 2. Replace the "11" with the number of hours your timezone is ahead of GMT (ie., Australian daylight savings time is 11 hours ahead of GMT) Step 3. In files where the date or time is displayed onscreen or written to the database, replace time() with TIME and now() with NOW ( ie., checkout_process.php, whos_online.php, login.php, orders.php etc.) * For SQL queries replace now() with '" . NOW . "' Good luck, Mark. Link to comment Share on other sites More sharing options...
Guest Posted February 25, 2003 Share Posted February 25, 2003 Rather than mess with counting timezones, just let the system solve that for you. putenv("TZ=US/Pacific"); Now all the times returned by the system will be in US/Pacific. If you want to know what timezones your server understands (on a unix system) try looking in: ls /usr/share/zoneinfo/ :idea: Link to comment Share on other sites More sharing options...
emiliano Posted February 27, 2003 Share Posted February 27, 2003 and your those using windows to test and *nix hosting the complete list is.... cheers emiliano patagonia, argentina Link to comment Share on other sites More sharing options...
Guest Posted February 27, 2003 Share Posted February 27, 2003 I have no clue. whats a windoze? :twisted: Link to comment Share on other sites More sharing options...
smiley Posted February 27, 2003 Share Posted February 27, 2003 Hi Met00, putenv("TZ=US/Pacific"); Would the above change the time the server displays :?: I live in Australia. My server lives in USA. Time difference of 11 hours. We need a simple way to work with that time difference. (My USA server suggested that his american customers did not want the time on the server to be offset by 11 hours). :roll: smiley "It does not do to leave a live dragon out of your calculations, if you live near him." J. R. R. TOLKIEN HTH Neil Common sense is genius dressed in working clothes. Ralph Waldo Emerson Link to comment Share on other sites More sharing options...
Guest Posted February 28, 2003 Share Posted February 28, 2003 Would the above change the time the server displays :?: The command will tell the unix server to return the date() function with the timezone that you provide. unix system provide the following: Austrailia/[enter one from list below - case counts] ACT Broken_Hill Hobart Lord_Howe NSW South Victoria Adelaide Canberra LHI Melbourne Perth Sydney West Brisbane Darwin Lindeman North Queensland Tasmania Yancowinna so, using one of those timezones all date() functions will return with the appropriate date/time for that timezone. To display the current user time use the following javascript function: <script language=JavaScript> <!-- Hide the script var months=new Array(13); months[1]="January"; months[2]="February"; months[3]="March"; months[4]="April"; months[5]="May"; months[6]="June"; months[7]="July"; months[8]="August"; months[9]="September"; months[10]="October"; months[11]="November"; months[12]="December"; var today=new Date(); var lmonth=months[today.getMonth () + 1]; var date=today.getDate(); var year=today.getFullYear(); var daynum = today.getDay() + 1; if(daynum==1) day = "Sunday"; if(daynum==2) day = "Monday"; if(daynum==3) day = "Tuesday"; if(daynum==4) day = "Wednesday"; if(daynum==5) day = "Thursday"; if(daynum==6) day = "Friday"; if(daynum==7) day = "Saturday"; var todaysdate= (day + ", " + date + " " + lmonth + " " + year); document.write(todaysdate); // end hiding--> </SCRIPT> [you could modify the above to include a running time clock if you like, but most people know their time :) ] Link to comment Share on other sites More sharing options...
smiley Posted February 28, 2003 Share Posted February 28, 2003 Thanks Met00, The js works great in displaying current time in the browser. putenv() is really to display local order time in confirmation emails. I found something at http://www.php.net/manual/en/function.putenv.php - bottom of the page. 'You would have to add a putenv() call to each page in which you wanted to change the timezone.' Is this is what you recommend - added to every file that handles orders - orders.php etc. etc.? IF so where in the code would you recommend. OR could it be implemented in application_top.php :?: IF so where in the code would you recommend. [i have an analog clock that follows the cursor around the page - bit of a nuisance really] HTH Neil Common sense is genius dressed in working clothes. Ralph Waldo Emerson Link to comment Share on other sites More sharing options...
Guest Posted March 2, 2003 Share Posted March 2, 2003 I put my putenv() for the timezone into application_top.php Link to comment Share on other sites More sharing options...
Druide Posted March 7, 2003 Share Posted March 7, 2003 just for those who are hosting their website on a external HOST most hosting company's have disabled the command putenv() So then you have to change a whole lot of files :( Robert We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;) Link to comment Share on other sites More sharing options...
eureka Posted March 7, 2003 Author Share Posted March 7, 2003 What's wrong with the original post? Easy to implement, not many files to change . . . . and it works. Mark. :) Link to comment Share on other sites More sharing options...
Guest Posted March 7, 2003 Share Posted March 7, 2003 What's wrong with the original post? Easy to implement, not many files to change . . . . and it works. Mark. :) I am doing development on three stores at this time. One client has not indicated where they will be hosting, one is hosting in Hong Kong and needs US/Pacific and another hosting in Hong Kong needs US/Central. By making one change to application_top I have one place where I change one line of code from my "base" and thereafter *any* call to a time function will use the correct timezone. Link to comment Share on other sites More sharing options...
bdownes Posted March 12, 2003 Share Posted March 12, 2003 I did the putenv() and it works great for showing the current date on the website. How about getting the Date/Time of Purchase to match up with my Time Zone (Pacific Standard Time). My server is in the EST. So my orders are showing up with EST times. Thank! Bobby Jared Geesey Link to comment Share on other sites More sharing options...
ozstar Posted March 12, 2003 Share Posted March 12, 2003 I have MS1 and trying to get this working for our Sydney account on a USA EST host. Have done the app top files okay but have been only able to find 1 'now()' in checkout_process. Nothing in login.php, orders.php, who's etc. In fact I dont have the time on the shop at all, just the date and day along the bottom where it also says so many requests since blah! Where do I turn this function on? Also.. I have phpMyAdmin, but not sure how to replace 'now' with 'NOW' in SQL. Thanks.. OZ Link to comment Share on other sites More sharing options...
eureka Posted March 12, 2003 Author Share Posted March 12, 2003 Ozstar, You need to look for both now() and time() across the enitre admin and catalog directories, try a program such as syn - freeware (http://syn.sourceforge.net/ or http://www.webattack.com/get/syn.shtml) and do a search for now() and time(). You'll easily find them. I didn't use MS1 but doing a quick search I found the following examples. Eg. /admin/orders.php - line 37 (and similar at line 50) was: tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . tep_db_input($status) . "', last_modified = now() where orders_id = '" . tep_db_input($oID) . "'"); change to: tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . tep_db_input($status) . "', last_modified = '".NOW."' where orders_id = '" . tep_db_input($oID) . "'"); /catalog/login.php - line 44 change to: tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_of_last_logon = '".NOW."', customers_info_number_of_logons = customers_info_number_of_logons+1 where customers_info_id = '" . $customer_id . "'"); /admin/whos_online.php - line 13 (and similar at 69) was: $xx_mins_ago = (time() - 900); change to: $xx_mins_ago = (TIME - 900); Also, the time isn't actully displayed on your webpage footer, only the date (which can be incorrect if your server time isn't adjusted accordinly). The time is most visible on 'report' pages within admin. Hope this assists. Mark. Link to comment Share on other sites More sharing options...
ozstar Posted March 12, 2003 Share Posted March 12, 2003 Thanks Mark ,appreciate the help.. Have a good one ! :) Link to comment Share on other sites More sharing options...
Floob Posted March 16, 2003 Share Posted March 16, 2003 Hmmm doesn't work for me. I'm using MS1. I put // Defining time to offset server define ('TIME', strtotime(gmstrftime("%Y-%m-%d %H:%M:%S", strtotime ("- 7 hour")))); define ('NOW', gmdate ('Y-m-d H:i:s', time() - 7 *3600)); in my application_top.php in the admin area. And replaced: /admin/whos_online.php - line 13 (and similar at 69) was: $xx_mins_ago = (time() - 900); change to: $xx_mins_ago = (TIME - 900); But when I look at whos online in admin the times are still wrong. Any ideas? Link to comment Share on other sites More sharing options...
ozstar Posted March 17, 2003 Share Posted March 17, 2003 HI, Did you change 'ALL' the now to NOW and time to TIME? I'm just about to change mine. I'll report back Link to comment Share on other sites More sharing options...
ozstar Posted March 17, 2003 Share Posted March 17, 2003 Hi, I have used syn but there are many files to change, or according to my search anyway.. for example. time() = 6 files in /catalog/ and 8 in /catalog/admin now() = 516 files in both dirs Got to be something wrong with the latter. Time is easy enough, but how does one know which of the 516 to change for now() Thanks :? Link to comment Share on other sites More sharing options...
Druide Posted March 17, 2003 Share Posted March 17, 2003 Ozstar, You need to look for both now() and time() across the enitre admin and catalog directories, try a program such as syn - freeware (http://syn.sourceforge.net/ or http://www.webattack.com/get/syn.shtml) and do a search for now() and time(). You'll easily find them. I didn't use MS1 but doing a quick search I found the following examples. Eg. /admin/orders.php - line 37 (and similar at line 50) was: tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . tep_db_input($status) . "', last_modified = now() where orders_id = '" . tep_db_input($oID) . "'"); change to: tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . tep_db_input($status) . "', last_modified = '".NOW."' where orders_id = '" . tep_db_input($oID) . "'"); /catalog/login.php - line 44 change to: tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_of_last_logon = '".NOW."', customers_info_number_of_logons = customers_info_number_of_logons+1 where customers_info_id = '" . $customer_id . "'"); /admin/whos_online.php - line 13 (and similar at 69) was: $xx_mins_ago = (time() - 900); change to: $xx_mins_ago = (TIME - 900); Also, the time isn't actully displayed on your webpage footer, only the date (which can be incorrect if your server time isn't adjusted accordinly). The time is most visible on 'report' pages within admin. Hope this assists. Mark. don't forget to change also catalog/includes/functions/whos_online.php $current_time = time(); to $current_time = TIME; else it has no effect i just noticed...lol Robert We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;) Link to comment Share on other sites More sharing options...
Floob Posted March 17, 2003 Share Posted March 17, 2003 I'm seeing some instances of now() as well as 'now()' So do these both change to '".NOW."' or do I do ''".NOW."'' ??? Link to comment Share on other sites More sharing options...
ozstar Posted March 17, 2003 Share Posted March 17, 2003 Hi, I am still unsure whether ALL these instances of now() (over 500), must be changed and if so is everything left EXACTLY as it is and the '".NOW."' inserted in its place? In syn do we just use replace now() with '".NOW."' ?? What about these ? ', now())"); now() (now()) and the other thing, how does one do a replace Query in the dbase? I use phpMyAdmin. I quick little walk thru would be great! Thanks :( Link to comment Share on other sites More sharing options...
Druide Posted March 18, 2003 Share Posted March 18, 2003 that ALL depends of the php coding ofourse [*] if it's in a SELECT / UPDATE / DELETE query [*] if it's in a string in <?php etc.. [*] ... [*] and more & more too much too explain to make a long story short. it takes a lot of effort / time to do this, also i would advice to have some skills in PHP to be sure that you will not mess up the structure in all files. I do NOT advise a search / replace in all files at the same time !! It's just too easy to make mistakes like you just gave examples from above I'm seeing some instances of now() as well as 'now()' So do these both change to '".NOW."' or do I do ''".NOW."'' ??? Robert We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;) Link to comment Share on other sites More sharing options...
ozstar Posted March 18, 2003 Share Posted March 18, 2003 Thanks.. Thought so!! Maybe Eureka who wrote the script can give us a list of the exact pages. That would save all this searching. In the meantime I'll just undo all I started.. Shame ! :cry: Link to comment Share on other sites More sharing options...
Druide Posted March 18, 2003 Share Posted March 18, 2003 why undo it, you can check each time if you changed another now() or time() correctly by accessing the right pages, or even easier look into phpMyAdmin or so Robert We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;) Link to comment Share on other sites More sharing options...
ozstar Posted March 18, 2003 Share Posted March 18, 2003 Hi Druid, See that's it.! I am still not sure which are the 'right' pages. If I knew that I would have gone in an manually doene every page that needed the change. I have done all the time() ones/ It is the now() that is the problem as there are so many with that code. It is still not clear to me or another poster evidently, whether one changes 'just' the now() or the other instances of wherever now() is written. (See above post) Also how to make the change in phpMyAdmin would be helpful. Would really love to get it right and I know many many Australian and NZ sites who have to go with the US times but this would give them an alternative. Once I understand it I will make very clear instructs so that those who follow can do it without this frustration. I notice that whulst it is part done, the date still shows on all the page but there is no date or time on the order form at all. Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.