Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

server time correction


cooch

Recommended Posts

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

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

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.

Link to comment
Share on other sites

  • 1 month later...

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

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

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

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.

Link to comment
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...