Changeset 8676
- Timestamp:
- 07/23/2014 06:07:39 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-functions.php
r8579 r8676 772 772 * 773 773 * @param bool $gmt True to use GMT (rather than local) time. Default: true. 774 * @param string $type See the 'type' parameter in {@link current_time()}. 775 Default: 'mysql'. 774 776 * @return string Current time in 'Y-m-d h:i:s' format. 775 777 */ 776 function bp_core_current_time( $gmt = true ) {777 // Get current time in MYSQL format778 $current_time = current_time( 'mysql', $gmt );778 function bp_core_current_time( $gmt = true, $type = 'mysql' ) { 779 // Get current time 780 $current_time = current_time( $type, $gmt ); 779 781 780 782 return apply_filters( 'bp_core_current_time', $current_time ); … … 841 843 * work out time elapsed between two known dates. 842 844 */ 843 $newer_date = ( !$newer_date ) ? strtotime( bp_core_current_time()) : $newer_date;845 $newer_date = ( !$newer_date ) ? bp_core_current_time( true, 'timestamp' ) : $newer_date; 844 846 845 847 // Difference in seconds -
trunk/tests/phpunit/testcases/core/functions.php
r8323 r8676 346 346 $this->assertNotEmpty( buddypress()->loaded_components['foo'] ); 347 347 } 348 349 /** 350 * @group bp_core_time_since 351 * @group bp_core_current_time 352 */ 353 public function test_bp_core_time_since_timezone_right_now() { 354 // backup timezone 355 $tz_backup = date_default_timezone_get(); 356 357 // set timezone to something other than UTC 358 date_default_timezone_set( 'Europe/Paris' ); 359 360 $this->assertSame( 'right now', bp_core_time_since( time() ) ); 361 362 // revert timezone back to normal 363 if ( $tz_backup ) { 364 date_default_timezone_set( $tz_backup ); 365 } 366 } 367 368 /** 369 * @group bp_core_time_since 370 * @group bp_core_current_time 371 */ 372 public function test_bp_core_time_since_timezone() { 373 // backup timezone 374 $tz_backup = date_default_timezone_get(); 375 376 // set timezone to something other than UTC 377 date_default_timezone_set( 'Europe/Paris' ); 378 379 $this->assertSame( '1 hour ago', bp_core_time_since( time() - 60*60 ) ); 380 381 // revert timezone back to normal 382 if ( $tz_backup ) { 383 date_default_timezone_set( $tz_backup ); 384 } 385 } 348 386 }
Note: See TracChangeset
for help on using the changeset viewer.