how can calculate
(now) - (date in database)
how can calculate
(now) - (date in database)
You can make a simple function where as $currenttime = the time now
, and $time = the time in the SQL
.
Just $product = $currenttime-$time
;
and then echo $product
MySQL:
SELECT CURDATE() - t.date
FROM TABLE t
SQL Server:
SELECT GETDATE() - t.date
FROM TABLE t
Oracle:
SELECT SYSDATE - t.date
FROM TABLE t
Bear in mind "now" (for the session) could be in one timezone and the database in a separate in a separate timezone. For Oracle, sysdate will use the database timezone and dates stored in the database without a timezone will be assumed to be in the database timezone.
alter session set time_zone='Europe/Zurich';
select sysdate, current_date from dual;
SYSDATE CURRENT_DATE
-------------------------- --------------------------
01/Feb/2010 16:08 01/Feb/2010 06:08