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. Quote 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 Quote 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")); Quote 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. Quote 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. Quote 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]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/137819-solved-date/#findComment-720877 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.