Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php date_default_timezone_set time() VS mysql now()

I am developing online shopping system. Only UK customers can place an order from the website.

I am wondering which is best method for me?

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

or

using mysql function now() ?

Sometime customer can select a time for delivery or collection.

Note: In the UK, we change the time twice a year!

like image 838
user622378 Avatar asked Apr 27 '11 13:04

user622378


1 Answers

If the time is being sent to the database, use NOW(); less overhead, and the server time zone is hopefully always going to be correct and less mutable than PHP's time zone. If we're just talking about display, without actually doing database work, then it's excessive to run a mysql query solely to get the time.

like image 59
Andrew Avatar answered Oct 07 '22 00:10

Andrew