cooch Posted November 30, 2009 Share Posted November 30, 2009 I didn't want to hi-jack another thread, but I have another question about server timezone being different from store timezone: I noticed that the now() function is used for most database entries. Can this be changed to something like now() + offset, where we define the offset to be a certain number of hours or a timestamp number? steve Link to comment Share on other sites More sharing options...
Guest Posted November 30, 2009 Share Posted November 30, 2009 Maybe these are what you want? Time Zone Offset - Adjust to match your location or Server Timezone fix 1.0 Link to comment Share on other sites More sharing options...
cooch Posted November 30, 2009 Author Share Posted November 30, 2009 Maybe these are what you want? Time Zone Offset - Adjust to match your location or Server Timezone fix 1.0 Have been following threads on those, and it seems like there are issues with them. Thought maybe a simple code change would work without the issues, but not sure if the now() function can be added to. Link to comment Share on other sites More sharing options...
MrPhil Posted November 30, 2009 Share Posted November 30, 2009 The idea is that database entries are always in GMT/UTC (Unix time system). When you want to display them for something, usually they will be formatted for the server's timezone properties (offset and DST). At that point you add an offset to the timestamp integer to kludge the different location between your server and your place of business/store. All forum software offers that capability (often both "system" offset for guests, and a further offset that individual users can add if they're not in the same timezone as the forum "is"). I haven't looked in detail at how osC handles time values, but you definitely would want to leave database entries in some standard format such as GMT/UTC. When formatting for display, add an overall offset (and possibly a customer offset). When comparing against some trigger time (at the place of business), the conversion of the local time to a timestamp should give a GMT/UTC value. Link to comment Share on other sites More sharing options...
♥FWR Media Posted November 30, 2009 Share Posted November 30, 2009 I would .. catalog/includes/application_top.php Find .. error_reporting(E_ALL & ~E_NOTICE); Change to .. error_reporting( E_ALL & ~E_NOTICE & ~E_DEPRECATED ); date_default_timezone_set("EUROPE/LONDON"); I used EUROPE/LONDON but find your timezone here By doing this you set your timezone correctly .. you prevent E_DEPRECATED errors when you move to PHP5.3. Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work. Link to comment Share on other sites More sharing options...
Laotan Posted January 18, 2010 Share Posted January 18, 2010 I would .. catalog/includes/application_top.php Find .. error_reporting(E_ALL & ~E_NOTICE); Change to .. error_reporting( E_ALL & ~E_NOTICE & ~E_DEPRECATED ); date_default_timezone_set("EUROPE/LONDON"); I used EUROPE/LONDON but find your timezone here By doing this you set your timezone correctly .. you prevent E_DEPRECATED errors when you move to PHP5.3. WOW, one of the easiest ways to adjust the time! Works Perfectly and perfect code - short and concise. Thanks! Link to comment Share on other sites More sharing options...
midpen Posted January 19, 2010 Share Posted January 19, 2010 I would .. catalog/includes/application_top.php Find .. error_reporting(E_ALL & ~E_NOTICE); Change to .. error_reporting( E_ALL & ~E_NOTICE & ~E_DEPRECATED ); date_default_timezone_set("EUROPE/LONDON"); I used EUROPE/LONDON but find your timezone here By doing this you set your timezone correctly .. you prevent E_DEPRECATED errors when you move to PHP5.3. I did this but doesn't work. Link to comment Share on other sites More sharing options...
MrPhil Posted January 20, 2010 Share Posted January 20, 2010 What does "doesn't work" mean? Are you getting an error message, or just the wrong time? What level of PHP are you running at? You need PHP 5.1 or higher for these changes to work. PHP 5.2 may possibly be required. Exactly what changes did you make to which file(s) to handle this? You'll want to make the same changes to the admin application_top.php, too. Updating my previous post, it appears that there may be a difference between time values saved with MySQL now() and PHP time(). Supposedly, now() may already include the server timezone offset, while time() is guaranteed to to be UTC/GMT. That needs to be taken into account when timestamps saved in the database are formatted. There also may be an erroneous timezone entry placed in your database ("/etc/GMT+n") that should be changed to a proper "region/city" entry. Link to comment Share on other sites More sharing options...
♥FWR Media Posted January 20, 2010 Share Posted January 20, 2010 What does "doesn't work" mean? Are you getting an error message, or just the wrong time? What level of PHP are you running at? You need PHP 5.1 or higher for these changes to work. PHP 5.2 may possibly be required. Exactly what changes did you make to which file(s) to handle this? You'll want to make the same changes to the admin application_top.php, too. Updating my previous post, it appears that there may be a difference between time values saved with MySQL now() and PHP time(). Supposedly, now() may already include the server timezone offset, while time() is guaranteed to to be UTC/GMT. That needs to be taken into account when timestamps saved in the database are formatted. There also may be an erroneous timezone entry placed in your database ("/etc/GMT+n") that should be changed to a proper "region/city" entry. Yeah, timestamp is a bit of a "gotcha" it certainly got me :) only good it seems for use where the server and script use the same timezone .. not a good idea to use in portable code then. Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work. Link to comment Share on other sites More sharing options...
midpen Posted January 21, 2010 Share Posted January 21, 2010 What does "doesn't work" mean? Are you getting an error message, or just the wrong time? What level of PHP are you running at? You need PHP 5.1 or higher for these changes to work. PHP 5.2 may possibly be required. Exactly what changes did you make to which file(s) to handle this? You'll want to make the same changes to the admin application_top.php, too. Updating my previous post, it appears that there may be a difference between time values saved with MySQL now() and PHP time(). Supposedly, now() may already include the server timezone offset, while time() is guaranteed to to be UTC/GMT. That needs to be taken into account when timestamps saved in the database are formatted. There also may be an erroneous timezone entry placed in your database ("/etc/GMT+n") that should be changed to a proper "region/city" entry. I made the changes in both application_top.php. Now the time on Who's Online is right, but on customers orders, still a wrong time. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.