Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL now() change timezone

I'm using the following INSERT statement:

INSERT INTO messages SET `to` = '".$to."', `from` = '".$this->userid."', `title` = '".$title."', `message` = '".$message."', `created` = NOW()

However, it uses my server time (America/Montreal). I want time zone of Asia (Asia/Calcutta)

Is this possible with the same query?

like image 997
Harinder Avatar asked May 23 '12 13:05

Harinder


1 Answers

Better use the SQL format directly in your query:

..`created` = CONVERT_TZ(NOW(),'SYSTEM','Asia/Calcutta')..
like image 159
Vlado Avatar answered Sep 18 '22 20:09

Vlado