Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: 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.
Posted 7-Aug-12 22:12pm
Edited 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";
                                  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";  ?>
  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
0 CPallini 385
1 BillWoodruff 334
2 Sergey Alexandrovich Kryukov 333
3 George Jonsson 285
4 OriginalGriff 267
0 OriginalGriff 5,095
1 CPallini 4,285
2 Sergey Alexandrovich Kryukov 3,767
3 George Jonsson 2,941
4 Gihan Liyanage 2,386


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 8 Aug 2012
Copyright © CodeProject, 1999-2014
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