I have time zone offset in my database field. and I need to compare (created_date + time zone offset) with (current date + time zone offset).
DATE(created_date + INTERVAL timezone_offset SECOND)
i know how to add time zone in created date field. but i have to add time zone with date("Y-m-d H:i:s).
I need the following in mysql query,
DATE("use php date function to get current date and time" + INTERVAL timezone_offset SECOND)
SQL Query Sample:
SELECT * FROM `admin` AS `A`
INNER JOIN `timezones` AS `T` ON `T`.`admin_id`=`A`.`admin_id`
WHERE (DATE(A.current_date + INTERVAL T.timezone_offset SECOND) != DATE('current datetime by php function ' + INTERVAL T.timezone_offset SECOND)))
Please help.
You can use date("Y-m-d H:i:s) function in you sql Query as following.
"SELECT * FROM `admin` AS `A`
INNER JOIN `timezones` AS `T` ON `T`.`admin_id`=`A`.`admin_id`
WHERE (DATE(A.current_date + INTERVAL T.timezone_offset SECOND) != DATE('".date("Y-m-d H:i:s")."' + INTERVAL T.timezone_offset SECOND)));"
You just have to add date("Y-m-d H:i:s") function in Sql Query.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With