sql和php中日期的差异
怎么计算呢sql和php中日期的差异,php,sql,mysql,sql-server,oracle,Php,Sql,Mysql,Sql Server,Oracle,怎么计算呢 (now) - (date in database) 您可以创建一个简单的函数,其中as$currenttime=现在的时间,而$time=SQL中的时间 只需$product=$currenttime-$time 然后echo$product您可以创建一个简单的函数,其中as$currenttime=现在的时间,而$time=SQL中的时间 只需$product=$currenttime-$time 然后是echo$productMySQL: SELECT CURDATE() -
(now) - (date in database)
您可以创建一个简单的函数,其中as
$currenttime=现在的时间
,而$time=SQL中的时间
只需$product=$currenttime-$time
然后
echo$product
您可以创建一个简单的函数,其中as$currenttime=现在的时间
,而$time=SQL中的时间
只需$product=$currenttime-$time
然后是echo$productMySQL:
SELECT CURDATE() - t.date
FROM TABLE t
SQL Server:
SELECT GETDATE() - t.date
FROM TABLE t
甲骨文:
SELECT SYSDATE - t.date
FROM TABLE t
MySQL:
SQL Server:
SELECT GETDATE() - t.date
FROM TABLE t
甲骨文:
SELECT SYSDATE - t.date
FROM TABLE t
请记住,“now”(对于会话)可能位于一个时区,而数据库可能位于另一个时区中的另一个时区。对于Oracle,sysdate将使用数据库时区,而存储在数据库中而不带时区的日期将假定在数据库时区中
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
请记住,“now”(对于会话)可能位于一个时区,而数据库可能位于另一个时区中的另一个时区。对于Oracle,sysdate将使用数据库时区,而存储在数据库中而不带时区的日期将假定在数据库时区中
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
你想要什么区别?秒?天?你想要什么区别?秒?天?