How to get time difference and active status in chatting system using php?
Get time difference and active status in chatting system using php
<?php $now_timestamp = strtotime(date('Y-m-d H:i:s')); $diff_timestamp = $now_timestamp - strtotime($end_time); if($diff_timestamp < 60){ echo "active now"; } if($diff_timestamp>=60 && $diff_timestamp<3600){ $get_diff = $diff_timestamp/60; echo "active " . intval($get_diff) . "m ago"; } if($diff_timestamp>=3600 && $diff_timestamp<86400){ $get_diff = $diff_timestamp/3600; echo "active " . intval($get_diff) . "h ago"; } if($diff_timestamp>=86400 && $diff_timestamp<(86400*30)){ $get_diff = $diff_timestamp/86400; echo "active " . intval($get_diff) . "d ago"; } if($diff_timestamp>=(86400*30) && $diff_timestamp<(86400*365)){ $get_diff = ($diff_timestamp/(86400*30)); echo "active " . intval($get_diff) . "m ago"; } if($diff_timestamp>=(86400*365)){ $get_diff = ($diff_timestamp/(86400*365)); echo "active " . intval($get_diff) . "y ago"; } ?>
POST COMMENTS