Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 7-Aug-12 22:13pm
v2

if the date is in ISO standard format i.e. "yyyy-mm-dd" then you can verify the date simple condition. as example:
C++
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";
}


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.
 
Share this answer
 
 
Share this answer
 
PHP
<?php $timezone = "Asia/Calcutta";<br mode="hold" /??>                                  if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone);
                  $d       =  date('Y-m-d');
                  $date    = $data['order_date'];
                  $e       =  date('Y-m-d',strtotime($date));
                 if($e == $d)
                                   {
echo "true";  ?>
<?php }else{ ??>echo "false"; ?>
 
Share this answer
 
v2
PHP
<?php $timezone = "Asia/Calcutta";<br mode="hold" /??>                                  if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone);
                  $d       =  date('Y-m-d');
                  $date    = $data['order_date'];
                  $e       =  date('Y-m-d',strtotime($date));
                 if($e == $d)
                                   {
echo "true";  ?>
<?php }else{ ??>echo "false"; ?>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900