mysql - Symfony Doctrine query entries by datetime and timezone -


i've got webservice written symfony. app calls , enters messages have send app @ specific time. cronjob on server runs every minute , checks messages have send. user can define time frame when whants receive messages.

i query messages following way:

$query = $em->createquery('     select m     mybundle:message m     inner join m.user u     m.active = true         , m.nextmessageon <= :now         , u.receivemessagesfrom <= :now         , u.receivemessagesto >= :now     order m.id asc ')->setparameter('now', new \datetime('now')); 

(for presentation purpose "from time" has before "to time")

now i've got problem, user can have different timezone server.

is there kind of best practice how handle hole time (datetime) / timezone / server / app problem? , symfony (doctrine) there clean way query items?

you should save correct timezone user in database , read this: http://docs.doctrine-project.org/en/latest/cookbook/working-with-datetime.html


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -