Using Variable for MySQL now()

Hi all, just a quick question, I’m tearing my hair out here! My servers time is incorrect and so therefore need to correct it by eight hours. Instead of going through every query, etc I thought it might be better to create a variable and just use that variable - making things much easier in the future should I need to change servers, etc. However the query is failing when I use the variable, any idea what is wrong? Any help is appreciated as always :slight_smile:

$mysql_now = 'date_add(now(), INTERVAL 8 HOUR';

$application = mysql_query(sprintf("
		INSERT INTO application_order 
		(customers_id, customers_name, customers_address, customers_telephone, customers_email, hire_start, hire_end, arrival_date, return_date,
		coupon_code, last_modified, date_purchased, order_status, order_total,
		order_discount, order_master_total, delivery_cost, 
		order_tax_rate, order_tax, ip_address) 
		VALUES('%f', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', $mysql_now, $mysql_now, '%f', '%f', '%f', '%f', '%f', '%s', '%f', '%s')", $_SESSION['USERS_ID'], $_SESSION['USERS_FULL_NAME'], $_SESSION['USERS_ADDRESS'], $_SESSION['USERS_TELEPHONE'],$_SESSION['USERS_EMAIL'], $_SESSION['DATES']['hire_start'], $_SESSION['DATES']['hire_end'], $_SESSION['DATES']['arrival_date'],$_SESSION['DATES']['return_date'], $_SESSION['COUPON_CODE'], '0', 
		$this->grand_total(1), $this->grand_total(1)-$this->grand_total(), 
		$this->grand_total(), $this->delivery_price($_SESSION['DELIVERY']),
		$this->vatRate, $this->grand_total()-$this->vatRemove($this->grand_total()), $_SERVER['REMOTE_ADDR']
		));

why not just fix your server’s time?

Hi, I have contacted my host and they said that the MySQL time cannot be changed. Therefore this is why I’m trying to use a global variable to control the time…

it’s time…

… for a new host :smiley:

okay, perhaps they have set their mysql server to UTC, and expect their clients (wherever they are, and that’s the key point) to adjust their apps accordingly

i must admit i don’t understand mysql’s time zone support

it’s worth a look in da manual, though

Yes maybe, apart from that I have had no problems and found them very good indeed (MediaTemple). Any ideas on a quick fix?