将当前日期与存储在MySQL表中的日期进行比较

问题描述:

如何通过php页面中的mysql数据库中的日期与服务器上的当前日期进行比较并获得一天的差异
请帮助我.

how can compare and get one day difference from current date on server with a date in the mysql database in a page in php
please help me.

如果日期采用ISO标准格式,即"yyyy-mm-dd",则可以验证日期简单条件.例如:
if the date is in ISO standard format i.e. "yyyy-mm-dd" then you can verify the date simple condition. as example:
if('2012-10-11' < '2012-10-10')
{
 echo "not true";
}

if('2012-10-11' > '2012-10-10')
{
 echo "true";
}

if('2012-10-11' <= '2012-10-11')
{
 echo "true";
}



如果不是ISO标准,则将其转换为ISO标准.顺便说一下,MySQL将日期存储为ISO标准,因此不必担心.但是如果您的输入框未在ISO标准中收到,则将其转换.



if it is not in ISO standard then convert it to ISO standard. By the way MySQL store date as ISO standard so don''t worry about it. but if your input box does not receive it in ISO Standard then convert it.


看看这些链接:

http://www.richardlord.net/blog/dates-in-php-and-mysql [ ^ ]

http://www.highlystructured.com/comparing_dates_php.html [
Take a look of those links:

http://www.richardlord.net/blog/dates-in-php-and-mysql[^]

http://www.highlystructured.com/comparing_dates_php.html[^]

Hope this helps :thumbsup:


<?php