At the moment I have this code:
$rawsql = "SELECT
*
FROM
numbers n
INNER JOIN
openings o ON n.id = o.branch_id AND o.dotw = DAYOFWEEK(CURRENT_DATE())
INNER JOIN
openings_times t ON o.id = t.opening_id
WHERE
(
UNIX_TIMESTAMP(CURRENT_TIMESTAMP())
BETWEEN UNIX_TIMESTAMP(CONCAT(CURRENT_DATE(), ' ', t.open)) AND UNIX_TIMESTAMP(CONCAT(CURREN开发者_StackOverflow社区T_DATE(), ' ', t.close))
)
AND
(
n.id = %d
);";
which is used to run an opening-times query. I have a variable $latest_ping, which basically contains the latest time that a user has 'pinged' the database.
If possible, I would like to replace the CURRENT_TIMESTAMP with this $latest_ping variable, because we want to use different timezones etc.
I have tried things like
UNIX_TIMESTAMP($latest_ping) and time($latest_ping) but they didn't work.
Any help would be greatly appreciated.
Give a try with
UNIX_TIMESTAMP(date_format("$latest_ping", '%Y-%c-%d %k:%i:%s' ))
Edit : actually it is also not needed. Make sure the date is formated as it is used in mysql
精彩评论