mikhell Posted October 18, 2010 Share Posted October 18, 2010 I try to get how long my message was sent with this... $Now = strtotime ("now"); $dateEnvoi = $fetchDiscussion['dateEnvoi']; //my date from my DB $timeEnvoi = mktime($dateEnvoi); $TempsEnvoi = $dateNow - $dateEnvoi; and it try to get how long it was post ... same thing as on facebook... like the 26 minutes ago from FB how can i do it ? Link to comment https://forums.phpfreaks.com/topic/216180-get-the-date-how-long-it-get-post/ Share on other sites More sharing options...
mikhell Posted October 20, 2010 Author Share Posted October 20, 2010 no body are able to ? Link to comment https://forums.phpfreaks.com/topic/216180-get-the-date-how-long-it-get-post/#findComment-1124348 Share on other sites More sharing options...
Buddski Posted October 20, 2010 Share Posted October 20, 2010 So you are trying to calculate how long ago a post was made? How is the date stored in your database? a date format like 2010-04-01 or and integer? Link to comment https://forums.phpfreaks.com/topic/216180-get-the-date-how-long-it-get-post/#findComment-1124350 Share on other sites More sharing options...
mikhell Posted October 20, 2010 Author Share Posted October 20, 2010 Yep... but is my way is ok ? or i'm lost ? and how can i do it simple as possible ? Link to comment https://forums.phpfreaks.com/topic/216180-get-the-date-how-long-it-get-post/#findComment-1124351 Share on other sites More sharing options...
Buddski Posted October 20, 2010 Share Posted October 20, 2010 It all depends on how the data in the database is stored as how I can help you proceed. If it is stored as a DateTime use this // If it is stored as a DateTime use this $stored_date = strtotime($fetchDiscussion['dateEnvoi']); $time_diff = time() - $stored_date; // If stored as a unix timestamp use this $time_diff = time() - $fetchDiscussion['dateEnvoi']; Then use PHP date function to display the date correctly. http://php.net/manual/en/function.date.php Link to comment https://forums.phpfreaks.com/topic/216180-get-the-date-how-long-it-get-post/#findComment-1124356 Share on other sites More sharing options...
mikhell Posted October 20, 2010 Author Share Posted October 20, 2010 if its a timestamp... :-\ should i change it for a datetime ? Link to comment https://forums.phpfreaks.com/topic/216180-get-the-date-how-long-it-get-post/#findComment-1124359 Share on other sites More sharing options...
Buddski Posted October 20, 2010 Share Posted October 20, 2010 Doesnt really matter. Both ways can be processed by PHP. Link to comment https://forums.phpfreaks.com/topic/216180-get-the-date-how-long-it-get-post/#findComment-1124360 Share on other sites More sharing options...
mikhell Posted October 20, 2010 Author Share Posted October 20, 2010 Thank you very much man !!! Link to comment https://forums.phpfreaks.com/topic/216180-get-the-date-how-long-it-get-post/#findComment-1124374 Share on other sites More sharing options...
mikhell Posted October 20, 2010 Author Share Posted October 20, 2010 $dateEnvoi = $fetchDiscussion['dateEnvoi']; $stored_date = strtotime($fetchDiscussion['dateEnvoi']); $tempsDiff = time() - $stored_date; How can i convert it to minute like : $tempsDiff / 60 = minutes ? Link to comment https://forums.phpfreaks.com/topic/216180-get-the-date-how-long-it-get-post/#findComment-1124375 Share on other sites More sharing options...
mikhell Posted October 20, 2010 Author Share Posted October 20, 2010 I GOT IT !!! THANK YOU SOOOO MUCH MAN ! i'm very happy Link to comment https://forums.phpfreaks.com/topic/216180-get-the-date-how-long-it-get-post/#findComment-1124382 Share on other sites More sharing options...
mikhell Posted October 20, 2010 Author Share Posted October 20, 2010 How can I get the day like monday or thursday in string? and how for the today date ? Link to comment https://forums.phpfreaks.com/topic/216180-get-the-date-how-long-it-get-post/#findComment-1124404 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.