Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Adjusting sites time - again


eureka

Recommended Posts

Posted

I've defined the following in application_top.php and successfully used it to replace PHPs time() function when needed (ie., footer.php, whos online etc.) to offset my stores time (by 11 hours) from my offshore host.

 

define ('TIME', strtotime(gmstrftime("%b %d %Y %H:%M:%S", strtotime ("- 11 hour"))));

 

However, this doesn't work for mySQL's now() function when writing to the database. Is there a similar way I can replace the now() function?

 

Thanks.

  • 9 months later...
Posted

This has probably been answered in another forums.. but so this isn't a dead end when people search here is a solution for the now() function which places the local server time of the mysql server as the time.

 

in a file which has global access to all files define your time area (application_top.php is a good one)

 

$aus_date_time = date ('Y-m-d H:i:s', time () + 59400);

 

you will want to play around with the timing on the end its in seconds and is currently set to SA time from a US server.

 

if you have trouble finding the right time create a blank php file with this in it

 

<?php

$aus_date_time = date ('Y-m-d H:i:s', time () + 59400);

echo $aus_date_time;

?>

 

This will echo what you will be replacing the now() function with.

 

now come the bit that takes a little longer.. you need to go thru all your files and find occurances of the now(), just a few notes when replacing them.

 

If you are using a linux operating system use this command

 

grep -sl 'now()' `find .` | more

 

1. If the now() is located in a mysql query/insert you need to put quotes around it eg

'" . $aus_date_time . "'

 

2. If the now() is located in an insert into an array just put in the $aus_date_time as the value without quotes

 

hopefully this isn't 2 long winded for everyone but I hope it helps you :D

 

------------------------

Galen

 

Note: hopefully the OSC team will implement something like this as once done it will be easy to change the date/time to any area and would be easily implemented into the config, The whole process only took me about 20 mins...

Posted

just another thing make sure that the definition of the $aus_date_time is located in both catalog/admin/application_top.php and catalog/application_top

 

G

  • 3 weeks later...
Posted
1. If the now() is located in a mysql query/insert you need to put quotes around it eg
'" . $aus_date_time . "'

 

2. If the now() is located in an insert into an array just put in the $aus_date_time as the value without quotes

Hi Galen,

 

I have been battling with this time issue for a long time and am relieved to see a solution. Please clarify a couple of things for me so I can get started on this.

 

Excuse my ignorance, but how do I tell whether now() is a mysql insert or a insert to an array....how would I pick up the difference in the various php files? Dreamweaver did a search across all pages and found many instances on now(), so I don't want to replace the wrong ones with the wrong string....

 

thanks a ton

Dominic

Archived

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

×
×
  • Create New...