Our website used to be hosted in the US, but has since been moved to the UK. The the problem is somewhere in the php code the time has been set to 6 hours behind UK time, which was correct for when the site was hosted in the USA. Now its in the UK, when A customer places an order, it does not show on our order downloads for 6 hours and in some cases counts as an order for the following day. I have looked through the php file and found these lines of code, does anyone know what I should change to correct this error?

$extime = time() + (365 * 24 * 60 * 60);

         $dcsql = "INSERT INTO discounts VALUES('','cosmoscode','".$cucode."',1500,0,10,0,'active',1,'".time()."','".$extime."','')";

and $tictime = time() + (3600 * 6); and $ordersql1 = $ordersql1.$_POST["transactiontime"]."','NULL','".$_POST['cctype']."',".$torderstatus.",'',".$tictime.",0,";

Recommended Answers

All 3 Replies

It's not completely obvious to me what's going on here, as I don't know the meaning behind $extime and $tictime .

The one thing that stands out to me, though (simply because it parallels the problem you're describing), is this line:

$tictime = time() + (3600 * 6);

It adds 6 hours to $tictime , which seems like it could coincide with a 6 hour delay. From another perspective, that doesn't make sense, because you had to subtract 6 hours while being hosted in the US.

Thanks for your reply, it was a big help!

See the code below, it explains $extime and $tictime

 $extime = time() + (365 * 24 * 60 * 60);
 $tictime = time() + (3600 * 6);

Can you explain $extime, i thought I understood as being:
days in a year, hours in a day, minutes in an hour and seconds in a minute.
But now I cant see why they need to be added together and what does the 3600 refer to in $tictime?

If i wanted to reverse the effect of the 6 would I use an minus sign instead of the?

The one thing that stands out to me, though (simply because it parallels the problem you're describing), is this line:

$tictime = time() + (3600 * 6);

It adds 6 hours to $tictime, which seems like it could coincide with a 6 hour delay. From another perspective, that doesn't make sense, because you had to subtract 6 hours while being hosted in the US.

Here's what PHP is doing in both of those time-related statements: PHP interprets time() to be the number of seconds since the start of the year 1970. What you are doing in each of your statements is adding a particular number of seconds to PHP's current time (also in seconds). Here's the PHP manual page referring to this.

In your $extime statement, you are adding a year's worth of seconds to PHP's current time, and in the $tictime statement you are adding 6 hours (using seconds as a measuring unit, again) to PHP's current time. PHP gets its current time from the operating system in which it resides. You can determine which timezone PHP believes itself to be in by looking at the information generated using the phpinfo() function (look under the 'date' heading).

Back to your question about $tictime : The 3600 number is simply 60 * 60; whoever wrote the code just decided not to split that up for the application. It could just as well have been written (60 * 60 * 6) .

Finally, I don't know if changing the $tictime line to this:

$tictime = time() - (3600 * 6);

will do anything for you, simply because I don't know the internals of your application. It certainly wouldn't hurt to try, though!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.