jaisol99 Posted October 29, 2009 Share Posted October 29, 2009 I have a mysql table with a timestamp field, which gives me "2009-10-27 20:30:35" (more than 1 day ago ..) I'm trying to calculated how many days it is since a user loged in. I figured $time_now = date('u') $time_from_table = date('u', strtotime("2009-10-27 20:"30:35") $time_now - $time_from_table = $the_number of seconds I always get 0 back as an aswer I've tried the calculation as date('c', ....) and its still the same Link to comment https://forums.phpfreaks.com/topic/179558-problem-with-date-time-calculations/ Share on other sites More sharing options...
sKunKbad Posted October 30, 2009 Share Posted October 30, 2009 I never liked the way MySQL stored dates. I just use php's time() when inserting into the database. It makes doing time comparisons a lot easier for me. Your field in the database becomes int(10) Link to comment https://forums.phpfreaks.com/topic/179558-problem-with-date-time-calculations/#findComment-947534 Share on other sites More sharing options...
jaisol99 Posted October 30, 2009 Author Share Posted October 30, 2009 LOL It all seemed so easy when I created the table... mysql Timestamp Ahhhhh I think its going to become a unix datetime tommorow, normaly when I ask a question here there's an answer in 10 mins with way better code than I can come up with, its been a few hours and there's no surgestions for converting or getting the timestamp in a format that I can do calculations with.... your thoughts are apreciated, Link to comment https://forums.phpfreaks.com/topic/179558-problem-with-date-time-calculations/#findComment-947598 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.