Changeset 599 for trunk/include/functions.inc.php
- Timestamp:
- Nov 10, 2004, 12:11:36 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions.inc.php
r593 r599 361 361 // 362 362 // format_date( "2003-09-15", 'us', true ) -> "Monday 15 September 2003 21:52" 363 function format_date( $date, $type = 'us', $show_time = false)363 function format_date($date, $type = 'us', $show_time = false) 364 364 { 365 365 global $lang; 366 366 367 list($year,$month,$day,$hour,$minute,$second) = array(0,0,0,0,0,0); 368 367 369 switch ( $type ) 368 370 { 369 case 'us' : 370 list( $year,$month,$day ) = explode( '-', $date ); 371 $unixdate = mktime(0,0,0,$month,$day,$year); 372 break; 373 case 'unix' : 374 $unixdate = $date; 375 break; 376 case 'mysql_datetime' : 377 preg_match( '/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/', 378 $date, $matches ); 379 $unixdate = mktime($matches[4],$matches[5],$matches[6], 380 $matches[2],$matches[3],$matches[1]); 381 break; 382 } 383 $formated_date = $lang['day'][date( "w", $unixdate )]; 384 $formated_date.= date( " j ", $unixdate ); 385 $formated_date.= $lang['month'][date( "n", $unixdate )]; 386 $formated_date.= date( ' Y', $unixdate ); 387 if ( $show_time ) 388 { 389 $formated_date.= date( ' G:i', $unixdate ); 371 case 'us' : 372 { 373 list($year,$month,$day) = explode('-', $date); 374 break; 375 } 376 case 'unix' : 377 { 378 list($year,$month,$day,$hour,$minute,$second) = 379 explode('.', date('Y.n.j.G.i', $date)); 380 break; 381 } 382 case 'mysql_datetime' : 383 { 384 preg_match('/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/', 385 $date, $out); 386 list($year,$month,$day,$hour,$minute,$second) = 387 array($out[1],$out[2],$out[3],$out[4],$out[5],$out[6]); 388 break; 389 } 390 } 391 $formated_date = ''; 392 // before 1970, Microsoft Windows can't mktime 393 if ($year >= 1970 or substr(PHP_OS, 0, 3) != 'WIN') 394 { 395 $formated_date.= $lang['day'][date('w', mktime(0,0,0,$month,$day,$year))]; 396 } 397 $formated_date.= ' '.$day; 398 $formated_date.= ' '.$lang['month'][(int)$month]; 399 $formated_date.= ' '.$year; 400 if ($show_time) 401 { 402 $formated_date.= ' '.$hour.':'.$minute; 390 403 } 391 404
Note: See TracChangeset
for help on using the changeset viewer.