I am trying to convert plain MySQL query to Doctrine query builder in Symfony2. I had a following part of SELECT query calculating different between the UTC timestamp in rcv.rtcdatetime field and current UTC:
TIMESTAMPDIFF(SECOND, rcv.rtcdatetime, UTC_TIMESTAMP()) AS utcdiff
Apparently the UTC_TIMESTAMP() function is not available in Doctrine. I managed to find CURRENT_TIMESTAMP() function in Doctrine but I cannot find what value is supposed to be returned by that function. Is it the local server time or UTC timestamp? I tested it on several servers and still not sure.
This library is able to extend Doctrine ORM with the TIMESTAMPDIFF
function: https://github.com/orocrm/doctrine-extensions
The calculation that the function does is however still executed on the mySQL Server:
The Mysql Server has serveral ways to configure the timezone internally used for all the operations. By default it should match your systems Timezone.
Read more about it here: https://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.