Changeset 9618
- Timestamp:
- 03/11/2015 08:58:29 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-template.php
r9617 r9618 273 273 274 274 /** 275 * Format a date. 276 * 277 * @param int $time The UNIX timestamp to be formatted. 278 * @param bool $just_date Optional. True to return only the month + day, false 279 * to return month, day, and time. Default: false. 280 * @param bool $localize_time Optional. True to display in local time, false to 281 * leave in GMT. Default: true. 282 * @return string|bool $localize_time Optional. A string representation of 283 * $time, in the format "January 1, 2010 at 9:50pm" (or whatever your 284 * 'date_format' and 'time_format' settings are). False on failure. 285 */ 286 function bp_format_time( $time = '', $just_date = false, $localize_time = true ) { 275 * Format a date based on a UNIX timestamp 276 * 277 * This function can be used to turn a UNIX timestamp into a properly formatted 278 * (and possibly localized) string, userful for ouputting the date & time an 279 * action took place. 280 * 281 * Not to be confused with `bp_core_time_since()`, this function is best used 282 * for displaying a more exact date and time vs. a human-readable time. 283 * 284 * Note: This function may be improved or removed at a later date, as it is 285 * hardly used and adds an additional layer of complexity to calculating dates 286 * and times together with timezone offsets and i18n. 287 * 288 * @since BuddyPress (1.1.0) 289 * 290 * @param int $time The UNIX timestamp to be formatted. 291 * @param bool $exclude_time Optional. True to return only the month + day, false 292 * to return month, day, and time. Default: false. 293 * @param bool $gmt Optional. True to display in local time, false to 294 * leave in GMT. Default: true. 295 * 296 * @return mixed A string representation of $time, in the format 297 * "March 18, 2014 at 2:00 pm" (or whatever your 298 * 'date_format' and 'time_format' settings are 299 * on your root blog). False on failure. 300 */ 301 function bp_format_time( $time = '', $exclude_time = false, $gmt = true ) { 287 302 288 303 // Bail if time is empty or not numeric … … 293 308 294 309 // Get GMT offset from root blog 295 if ( true === $ localize_time) {310 if ( true === $gmt ) { 296 311 297 312 // Use Timezone string if set … … 315 330 } 316 331 317 // Current date (January 1, 2010)318 $formatted_date = date_i18n( bp_get_option( 'date_format' ), $calculated_time, $ localize_time);332 // Formatted date: "March 18, 2014" 333 $formatted_date = date_i18n( bp_get_option( 'date_format' ), $calculated_time, $gmt ); 319 334 320 335 // Should we show the time also? 321 if ( false === $just_date ) {322 323 // Current time (9:50pm)324 $formatted_time = date_i18n( bp_get_option( 'time_format' ), $calculated_time, $ localize_time);336 if ( true !== $exclude_time ) { 337 338 // Formatted time: "2:00 pm" 339 $formatted_time = date_i18n( bp_get_option( 'time_format' ), $calculated_time, $gmt ); 325 340 326 341 // Return string formatted with date and time
Note: See TracChangeset
for help on using the changeset viewer.