Full PHP class, usually I will cooperate with smary use, quick Use (plugins/function.rdate.php), more PHP technology development go to PHP Tutorial network, http://php.662p.com
<? php/* * Data time functions. * Module */defined (' Tsky ') | | Die (' Permission denied! '); function Fmtmonth ($month) {return date (' F, Y ', Day2time ($month. ') 01 '));} function Fmt_month ($ts) {return strftime ("%b,%y", $ts);} 03:02function Sharttime ($ts) {return strftime ("%h:%m", $ts);} 03:02:01function longtime ($ts) {return strftime ("%T", $ts);} April 18 function ShortDate ($ts) {return date ("N-month D-Day", $ts);} April 18, 2006 function Longdate ($ts) {return date ("Y year n ' d Day", $ts);} function DateTime ($ts) {return date ("Y year n ' d h:i:s", $ts);} function Fulldatetime ($ts) {return date ("Y year n ' d Day", $ts). Week ($ts); Function Week ($ts) {global $lang; return $lang [' WeekDay '][date (' W ', $ts)];} function Relatively_date ($date) {if (!preg_match ('/^\d+$/', $date)) $date = Strtotime (Trim ($date)); $sec = Time ()-$date; Switch (true) {case $sec < 3600:return round ($SEC/60). ' Minutes ago '; Case $sec < 86400:return round ($SEC/3600). ' Hour ago '; Case$sec < (86400 * 7): Return round ($sec/86400). ' days ago ';//days ago Case $sec < (86400 * 7 * 4): return round ($sec/(86400*7)). ' Weeks ago '; Weeks ago Default:return longdate ($date); }}function nextmonth ($month/*200512->200601*/) {return date (' Ym ', Strtotime (' +1 month ', Strtotime ($month. ') 01 ')));} function Prevmonth ($month/*200512->200511*/) {return date (' Ym ', Strtotime ('-1 month ', Strtotime ($month. ') 01 ')));} function Prevday ($day/*20050826*/) {$day = substr ($day, 0,8); Return date (' Ymd ', Strtotime ('-1 day ', Strtotime ($day)));} function NextDay ($day/*20050826*/) {$day = substr ($day, 0,8); Return date (' Ymd ', Strtotime (' +1 Day ', Strtotime ($day)));} function Nextexistsday ($day/*20050109*/) {$day = NextDay ($day); while (!hastopic ($day) && $day < TODAY) {$day = NextDay ($day); } return Hastopic ($day)? $day: false;} function Prevexistsday ($day/*20050109*/) {global $cfg; $day = Prevday ($day); while (!hAstopic ($day) && (int) $day > $cfg->origdate) {$day = Prevday ($day); } return Hastopic ($day)? $day: false;} function Prev_day ($day) {$day = substr ($day, 0,8), return date (' Ymd ', Strtotime ('-1 day ', Strtotime ($day)));} function Long_date ($ts) {return date ("Y year n month D Day", $ts);} function Day2time ($day) {return @strtotime ($day);} /*echo "<pre>"; Echo strftime ("a%a\n"); A Tuesday echo strftime ("a%a\n"); A Tuesday Echo strftime ("b%b\n"); b April Echo strftime ("b%b\n"); B April Echo strftime ("c%c\n"); C 2006-4-18 3:48:11 Echo strftime ("c%c\n"); C echo strftime ("d%d\n"); D-Echo strftime ("d%d\n"); D echo strftime ("e%e\n"); E echo strftime ("g%g\n"); G Echo strftime ("g%g\n"); G echo strftime ("h%h\n"); H Echo strftime ("h%h\n"); H 03Echo strftime ("i%i\n"); I-Echo strftime ("j%j\n"); J 108 Echo strftime ("m%m\n"); M echo strftime ("m%m\n"); M-Echo strftime ("n%n\n"); n Echo strftime ("p%p\n"); P am Echo strftime ("r%r\n"); R echo strftime ("r%r\n"); R echo strftime ("s%s\n"); S one echo strftime ("t%t\n"); T echo strftime ("t%t\n"); T echo strftime ("u%u\n"); U echo strftime ("u%u\n"); U echo strftime ("v%v\n"); V echo strftime ("w%w\n"); W echo strftime ("w%w\n"); W 2 echo strftime ("x%x\n"); X 2006-4-18 echo strftime ("x%x\n"); X 3:48:11 Echo strftime ("y%y\n"); Y Echo strftime ("y%y\n"); Y 2006 ECHo strftime ("z%z\n"); Z China Standard Time Echo strftime ("%%%\n"); // % */
Detailed Description: http://php.662p.com/thread-571-1-1.html
PHP version for a friendly time display (ex: 2 hours ago)