ohdang888 Posted December 20, 2008 Share Posted December 20, 2008 i have this timestamp: 2008-12-19 21:26:39 and i want to see how many days ago this was... how would i do that? thanks. Link to comment https://forums.phpfreaks.com/topic/137819-solved-date/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 20, 2008 Share Posted December 20, 2008 http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_datediff Link to comment https://forums.phpfreaks.com/topic/137819-solved-date/#findComment-720305 Share on other sites More sharing options...
.josh Posted December 20, 2008 Share Posted December 20, 2008 echo date("d", time() - strtotime("2008-12-19 21:26:39")); Link to comment https://forums.phpfreaks.com/topic/137819-solved-date/#findComment-720306 Share on other sites More sharing options...
.josh Posted December 20, 2008 Share Posted December 20, 2008 eh. fubar moment. That doesn't really work. you have to time-strtime but then do some math to break down years and months first, before using date. Link to comment https://forums.phpfreaks.com/topic/137819-solved-date/#findComment-720307 Share on other sites More sharing options...
ohdang888 Posted December 21, 2008 Author Share Posted December 21, 2008 hm... mysql time function is confusing.. any other ways? thanks. Link to comment https://forums.phpfreaks.com/topic/137819-solved-date/#findComment-720864 Share on other sites More sharing options...
redarrow Posted December 21, 2008 Share Posted December 21, 2008 try this <?php $sql="SELECT datediff('2008-12-19 21:26:39',now())"; $res=mysql_query($sql)or die(mysql_error()); echo $res[0]; ?> Link to comment https://forums.phpfreaks.com/topic/137819-solved-date/#findComment-720877 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.