php - date formatting from MySQL -


i have serious problem dealing data mysql. insert date upon form submission via php using now() , inserted table field date. upon retrieval db, subtract given 10 hours, , once @ 0 function executed. conversion not seem work keep getting errors. appreciated. in advance!

code:

//retrieval db $sql = mysql_query("select * `objectives` limit 0 , 30");  while ($data=mysql_fetch_array($sql)) {   $data['obj_date'];//2014-04-06   echo date('y-d')- $data['obj_date'];//0 } 

try this, can't subtract 2 dates you're doing in php have use strtotime change dates timestamps, subtract these 2, calculate want get...

<?php //$data['obj_date'];//2014-04-06 //difference in seconds $difference=strtotime(date("y-m-d")) - strtotime($data['obj_date']); //calculate number of days echo ($difference/86400).' days'; 

Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -