Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

Changing timestamp and timezone of your store


3 replies to this topic

#1 axioma

  • Community Member
  • 168 posts
  • Real Name:yesid borislov

Posted 01 April 2010, 18:08

Your store is located on London UK, but your web store is hosted on California USA, the orders and whois shows only the time of your hosting server California, BUT not the time of your store in London.

THE IDEA IS ONLY CHANGE THE TIMESTAMP IN YOUR SERVER INSTEAD CHANGE A LOT OF FILES IN YOUR ESTORE

Please backup first.

This configuration works on my hosting on Bluehost, try if this works for your server also... I HOPE SO.

Get your php.ini
Add inside

date.timezone = "Europe/London";

depending your time zone, Use the appropriate option at http://php.net/timezones

Within public_html create a file call it inilocaxx.php (to avoid that somebody guess the name) with the following syntax included within it:
<pre><?php system("find . -type d|xargs -i cp --verbose php.ini {}/."); ?></pre>COMPLETE!

Upload the file to public_html where you already have the initial php.ini (modified with the timezone) file, you would go to http://www.maindomain.com/ inilocaxx.php This will copy the file to every folder below public_html.
Now if you have your store in a subfolder you will want to change the subfolder only; so… upload the file to your storexyz where you already have place the php.ini (modified with the timezone) file, next, you would go to http://www.maindomai...z/inilocaxx.php This will copy the file to every folder below storexyz.
Also make this changes to your languages files

Ie
On
catalog/ includes/languages/english.php
find
@setlocale(LC_TIME, 'en_US.ISO_8859-1');
Change by

@setlocale(LC_TIME, 'en_GB');
@PUTENV('TZ=Europe/London');
@mktime('0,0,0,1,1,1970');

Admin/includes/languages/english.php

find
setlocale(LC_TIME, 'en_US.ISO_8859-1');

Change by
setlocale(LC_TIME, 'en_GB');
@PUTENV('TZ=Europe/London');
@mktime('0,0,0,1,1,1970');

I HOPE THAT WORKS FOR YOU TOO.

Edited by axioma, 01 April 2010, 18:10.


#2 geoffreywalton

  • Community Sponsor
  • 7,731 posts
  • Real Name:Geoffrey Walton
  • Gender:Male
  • Location:Norfolk, UK (close to the centre of the universe)

Posted 01 April 2010, 19:13

Or you could try the add on http://addons.oscommerce.com/info/5432 or http://addons.oscommerce.com/info/4156

But nice work!!
Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

Virus Threat Scanner
My Contributions
Basic install answers.
Click here for Contributions / Add Ons.
UK your site.
Site Move.
Basic design info.

For links mentioned in old answers that are no longer here follow this link Useful Threads.

If this post was useful, click the Like This button over there ======>>>>>.

#3 Winterburn

  • Community Member
  • 35 posts

Posted 23 May 2010, 03:46

Here is my 2 cents regarding the timezone changing on osCommerce.

First, add this on your application_top.php (on all includes)

date_default_timezone_set("ASIA/BANGKOK");

Of course, change the contents to your appropriate timezone.

This will change the way PHP date functions are displayed.

To change the timezone on a mySQL level, I have created this neat trick. I just don't know if it is failsafe or what.

On includes/functions/database.php, find the following lines:

function tep_db_query($query, $link = 'db_link') {
    global $$link;
....

and add the following below the "global" part:

	if (strstr($query, 'now()')) {
	  $datestr = date('Y-m-d H:i:s');
	  $query = str_replace('now()', "'" . $datestr . "'", $query);
	}

..also, find the "now()"'s and do this:

          case 'now()':
		    $datestr = date('Y-m-d H:i:s');
            $query .= "'" . $datestr . "', ";

and this:

          case 'now()':
		    $datestr = date('Y-m-d H:i:s');
            $query .= $columns . "'" . $datestr . "', ";


Basically, the code just replaces any occurrence of now() in your tep_db_query function and tep_db_perform function with a date outputted by the function date(). This will align the PHP date with the mySQL date.

#4 Yann

  • Community Member
  • 3 posts
  • Real Name:Yann

Posted 31 January 2011, 17:27

View PostWinterburn, on 23 May 2010, 03:46, said:

Here is my 2 cents regarding the timezone changing on osCommerce.

First, add this on your application_top.php (on all includes)

date_default_timezone_set("ASIA/BANGKOK");

Of course, change the contents to your appropriate timezone.

This will change the way PHP date functions are displayed.

To change the timezone on a mySQL level, I have created this neat trick. I just don't know if it is failsafe or what.

On includes/functions/database.php, find the following lines:

function tep_db_query($query, $link = 'db_link') {
    global $$link;
....

and add the following below the "global" part:

	if (strstr($query, 'now()')) {
	  $datestr = date('Y-m-d H:i:s');
	  $query = str_replace('now()', "'" . $datestr . "'", $query);
	}

..also, find the "now()"'s and do this:

          case 'now()':
		    $datestr = date('Y-m-d H:i:s');
            $query .= "'" . $datestr . "', ";

and this:

          case 'now()':
		    $datestr = date('Y-m-d H:i:s');
            $query .= $columns . "'" . $datestr . "', ";


Basically, the code just replaces any occurrence of now() in your tep_db_query function and tep_db_perform function with a date outputted by the function date(). This will align the PHP date with the mySQL date.

Hi,

This was working very fine for a while, then I suddenly started to get a 1064 SQL error. I'm not sure where the problem comes from (probably an SQL update) but the SQL error seems to appear only when you update a product (when you insert something in the DB, it's just fine). It just doesn't want to print the "=" after "products_last_modified", which results in the 1064 error. So I just replace this :

          case 'now()':
		    $datestr = date('Y-m-d H:i:s');
            $query .= $columns . "'" . $datestr . "', ";

By this :

          case 'now()':
		    $datestr = date('Y-m-d H:i:s');
            $query .= $columns . "='" . $datestr . "', ";

Not sure this is correct, but it works for me.