/ Published in: PHP
URL: http://php.net/manual/en/function.time.php
Expand |
Embed | Plain Text
<?php function nicetime($date) { return "No date provided"; } // check validity of date return "Bad date"; } // is it future date or past date if($now > $unix_date) { $difference = $now - $unix_date; $tense = "ago"; } else { $difference = $unix_date - $now; $tense = "from now"; } $difference /= $lengths[$j]; } if($difference != 1) { $periods[$j].= "s"; } return "$difference $periods[$j] {$tense}"; } $date = "2009-03-04 17:45"; $result = nicetime($date); // 2 days ago ?>
Comments
Subscribe to comments
You need to login to post a comment.

my date comes from php echo date("D-M-Y H:i:s", $rows->date_add); how would i implement this?
i got this working