Time Ago Function is a function that is commonly used to display time in human understandable format, as you have seen many times on social networks, whenever you post any status on your Facebook, Twitter or any other network, it says posted few seconds ago, 1 min ago, 1 hour age, etc. This is actually done by subtracting the current time from the post published time. //Creating Function function TimeAgo ( $oldTime , $newTime ) { $timeCalc = strtotime ( $newTime ) - strtotime ( $oldTime ) ; if ( $timeCalc >= ( 60 * 60 * 24 * 30 * 12 * 2 ) ) { $timeCalc = intval ( $timeCalc / 60 / 60 / 24 / 30 / 12 ) . " years ago" ; } else if ( $timeCalc >= ( 60 * 60 * 24 * 30 * 12 ) ) { $timeCalc = intval ( $timeCalc / 60 / 60 / 24 / 30 / 12 ) . " year ago" ; } else if ( $timeCalc >= ( 60 * 60 * 24 * 30 * 2 ) ) { $timeCalc = intval ( $timeCalc / 60 / 60 / 24 / 30 ) . " months ago" ; } else if ( $time...
Comments