I need a time comparison.
I have a database field with a varchar
field that contains column name date
.
I have fetched two dates on the bases of id.like
in code.
Now i want to convert these strings into actual date/time so I can compare them.
I am trying this:
$sql="SELECT date From tbl_info where id=12 "; //first date string
$sql2="SELECT date From tbl_info where id=14 "; //2nd date string
$result= mysql_query($sql) or die(msyql_error());
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$date=$row["date"]. "<br>";
echo $date ;
}
$result2= mysql_query($sql2) or die(msyql_error());
while($row2 = mysql_fetch_array($result2, MYSQL_ASSOC))
{
$date2=$row2["date"]. "<br>";
echo $date2;
}
$value=strtotime('H,i',$date);
echo "<br/>Value= :".$value ;
$value2=strtotime('H,i',$date2);
echo "<br/>Value2= :".$value2;
RESULTS:
Value= :-48386
Value2= :-48386
What is the actual way to do it right, because strtotime
does not work.