Click here to Skip to main content
13,145,603 members (43,800 online)
Rate this:
 
Please Sign up or sign in to vote.
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 7-Aug-12 22:12pm
Updated 7-Aug-12 22:13pm
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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";
}


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.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

<?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"; ?>
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

<?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"; ?>
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.170915.1 | Last Updated 8 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100