将当前日期与存储在MySQL表中的日期进行比较 [英] Comparing current date with a date stored in MySQL table

查看:92
本文介绍了将当前日期与存储在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 


这篇关于将当前日期与存储在MySQL表中的日期进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆