Jump to content

Search the Community

Showing results for tags 'time'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • WebFlake
    • Announcements and Updates
    • WebFlake Support
    • Member Introductions
    • Off-topic Lounge
    • Archives
  • Webmasters
    • Webmaster Lounge
    • Marketplace (Hire, Buy, Sell, Trade)
    • Coupons and Deals
    • Hosting
    • Website and Graphics Design
    • Website Showcase
  • Invision Community Suite
    • Invision Community Suite 4.7
    • Invision Support
    • Invision Requests
    • Invision Tutorials
    • Invision Beta
  • XenForo
    • XenForo 2.2
    • XenForo Support
    • XenForo Requests
    • XenForo Tutorials
  • WordPress
    • WordPress Content
    • WordPress Support
    • WordPress Requests
    • WordPress Tutorials
  • Unsupported Software
    • IPB 3.4 Legacy
    • IPS 4.x Legacy

Categories

  • Invision Community Suite 4.7
    • Applications and Plugins
    • Themes
    • Translations
    • Invision Extras
  • Invision Community Suite 4.6
    • Applications and Plugins
    • Themes
    • Translations
    • Invision Extras
  • Invision Community Suite 4.5
    • Applications and Plugins
    • Themes
    • Translations
    • Invision Extras
  • XenForo 2.2
    • Add-ons
    • Styles
    • Translations
    • Miscellaneous
  • XenForo 2.1
    • Add-ons
    • Styles
    • Translations
    • Miscellaneous
  • Wordpress
    • Themes
    • Plugins
  • ThemeForest
    • HTML
    • CMS
    • UI Design
    • JavaScript Code
  • CodeCanyon
    • PHP Scripts
    • JavaScript
    • CSS
    • HTML5
  • Graphics & Design
    • Emoticons & Smileys
    • Ranks & Badges
    • PSD & AI Designs
  • Unsupported Software
    • IPB 3.4
    • Invision Community Suite 4.4
    • Invision Community Suite 4.3
    • IPS Community Suite 4.2
    • IPS Community Suite 4.1
    • XenForo 2.0
    • MyBB 1.8

Product Groups

  • WebFlake Creative Designs
  • WebFlake Donation Bundles

Blogs


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Version

Found 1 result

  1. Following functions are very useful to you but they haven't built-in right into IP.Board yet. So you gotta add them manually. Those two functions as follows... 1. timespan( $timespanToDate ) - Counts how much time between a pass date your specify through parameters and today. 2. daysleft( $toDate ) - Counts how much days left for a future date you specify through parameters. You can use these functions as an example to show how much days left to christmas and/or how much time spent since your board started! Open admin/sources/classes/class_localization.php and add following code right after getTimeOffset() function. (You're free to place wherever you like, but remember to add it outside of functions and inside the class) /** * Timespan to get years, months, days and etc between a specified date and the current timestamp * * @access public * @param string Date target * @return string */public function timespan( $timespanToDate ){ if( !is_int( $timespanToDate ) ) { $timespanToDate = strtotime( $timespanToDate ); } $diff = abs( time() - $timespanToDate ); $years = floor( $diff / ( 365 * 60 * 60 * 24 ) ); $months = floor( ( $diff - $years * 365 * 60 * 60 * 24 ) / ( 30 * 60 * 60 * 24 ) ); $days = floor( ( $diff - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24 ) / ( 60 * 60 * 24 ) ); // $hours = floor( ( $diff - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24 - $days * 60 * 60 * 24 ) / ( 60 * 60 ) ); // $minutes = floor( ( $diff - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24 - $days * 60 * 60 * 24 - $hours * 60 * 60 ) / 60 ); // $seconds = floor( ( $diff - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24 - $days * 60 * 60 * 24 - $hours * 60 * 60 - $minutes * 60 ) ); $string = ""; if( $years AND $years >= 1 ) { $string .= $years. " years, "; } if( $months AND $months >= 1 ) { $string .= $months. " months and "; } if( $days AND $days >= 1 ) { $string .= $days. " days ago"; } return $string;}/** * Count how much days left from the current timestamp * * @access public * @param string Date target * @return integer */public function daysleft( $toDate ){ if( !is_int( $toDate ) ) { $toDate = strtotime( $toDate ); } $timeleftTime = $toDate - time(); $timeleftDays = round( ( ( $timeleftTime / 24 ) / 60 ) / 60 ); return $timeleftDays;} Indent the code once to keep the code structure intact. That's it! Enjoy using these in your board. Examples (PHP)... $this->registry->getClass('class_localization' )->timespan( '02 September 1993' );$this->registry->getClass('class_localization' )->daysleft( '05 April 2013' );
×
×
  • Create New...