简体   繁体   中英

MySQL - Select date by different timezone

I've a database with a column of date in UTC timezone.

Now I would like to preform a select query by different time zone (PST).

Is this possible?

Thanks

Could have a column specifying the time zone and than execute sql stmt like this

  " SELECT timeZone, timeStamp
    FROM tableName
    WHERE timeZone='UTC' "

could pass a variable in the where clause like this, this is how id do it in php

$TimeZone2Query = 'UTC';

" SELECT timeZone, timeStamp
  FROM tableName
  WHERE timeZone='$TimeZone2Query' "

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM