I'm developing shopping online system. Only United kingdom clients can make an order in the website.

I'm wondering that is most practical way for me personally?

date_default_timezone_set("Europe/London") $time = time()


using mysql function now() ?

Sometime customer can choose a period for delivery or collection.

Note: Within the United kingdom, we alter the time two times annually!

When the time has been delivered to the database, use NOW() less overhead, and also the server time zone is hopefully always likely to be correct and fewer mutable than PHP's time zone. If we are just speaking about display, without really doing database work, then it is excessive to operate a mysql query exclusively to obtain the time.

In PHP It's my job to perform the following:


After which, upon hooking up towards the MySQL server, I execute the next query:

'SET time_zone = "' . date_default_timezone_get() . '";'

This makes certain that both PHP and MySQL are utilizing the same timezone, so NOW() and date('Y-m-d H:i:s') should both yield exactly the same result.

Concerning the daylight changes, they should not be considered a problem (should you keep the software up-to-date).

One massive consideration within this real question is if the occasions are identical between PHP and MySQL?

When the two are running on a single machine then your answer will probably be 'yes', but when they are on separate machines plus there is a powerful possibility that they're going to actually differ.

Think about a scenario where dates are written to some database while using MySQL NOW() function, and individually you've got a query requesting all records made within the last 24 hrs, building time within the query while using PHP date functions. When the time around the PHP server has run out of sync using the SQL server, it reveals the chance that you might miss records out of your report (or have them bending-on consecutive days, based on which way to avoid it of sync they're). This can lead to shipping being skipped, etc.

The upshot of the is you should make sure remain consistent together with your utilization of dates (and particularly datetimes). It does not really matter whether you apply the PHP or MySQL date functionality, but gradually alter make use of the same platform to question while you accustomed to update.

Obviously, it isn't always likely to be critical in by doing this, and you will be practical about this - sometimes it is simply too bothersome to return to the DB, simply to discover exactly what the time is! However when it is important, you ought to be careful.

Naturally, when the two systems are on a single server, this can be a non-problem, however, you should not assume this can always be.