anujgarg Posted September 17, 2008 Share Posted September 17, 2008 i have two types of date format 2008-08-12 12:06:00 and 1221650951 (as a timestamp) Now I want to count total number of days and total time in hours from current date. How can I do it in both the cases? Link to comment https://forums.phpfreaks.com/topic/124636-count-number-of-days-and-total-time-in-hours/ Share on other sites More sharing options...
MatthewJ Posted September 17, 2008 Share Posted September 17, 2008 You can use strtotime on the first format $ts = strtotime('2008-08-12 12:06:00'); and then something like this maybe <?php $ts = '1221650951'; $difference = time() - $ts; $days = number_format(($difference / 86400), 2); $hours = number_format(($difference / 3600), 2); echo "Number of days since ".date('Y-m-d', $ts)." is $days"; echo "<br />"; echo "Number of hours since ".date('Y-m-d', $ts)." is $hours"; ?> Link to comment https://forums.phpfreaks.com/topic/124636-count-number-of-days-and-total-time-in-hours/#findComment-643705 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.