Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9137675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:09:22+00:00 2026-06-17T09:09:22+00:00

The controller passes $results to the View. The View has: <?php foreach ($results as

  • 0

The controller passes $results to the View.
The View has:

<?php foreach ($results as $result): ?>
<?php echo $result->time_start.' '.$result->time_finished;?>
<?php endforeach;?>

Also, I would like to display the difference ($result->time_finished minus $result->time_start) in format hh:mm:ss for each $result. If mm<10, then zero is shown, so 63 seconds are displayed as 00:01:03, not as 0:1:3.

Should I do all this staff in the view?
I believe it makes sense to use a function. Should I write this function in the model and call it from the view?

If not foreach, I would definitely call fhe function from the controller and pass the proper hh:mm:ss to the view from the controller.
But, what should I do in this case?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:09:23+00:00Added an answer on June 17, 2026 at 9:09 am

    If you have a function that you need to use multiple times in your code, it makes sense to 1. create your own helper or 2. extend Kohana’s build in Date helper. Helpers are used for this kind of operations, not the Model and if the code gets to complex, also not the view.

    I don’t know if you use Kohana 3.2 or 3.3, but there is a bit of a difference in naming convention between them (since 3.3 PSR-0 is implemented which means capitalized file and class names), but here are the DOCS for helpers:

    http://kohanaframework.org/3.2/guide/kohana/helpers

    http://kohanaframework.org/3.3/guide/kohana/helpers

    and for extending existing classes:

    http://kohanaframework.org/3.2/guide/kohana/files

    http://kohanaframework.org/3.3/guide/kohana/files

    I provide the answer if you use Kohana 3.2:

    Solution 1: It would make sense to extend the Kohana Date class. Create a file named date.php in application/classes. The file should look like this:

    class Date extends Kohana_Date {
      public static function some_function_to_convert($date1, $date2) { } ;
    }
    

    In your view do this: Date::some_function_to_convert($date1, $date2);

    Solution 2: Create your own helper in application/classes/helper dir. Name it date_conversion.php. Your file then looks like this:

    <?php defined('SYSPATH') or die('No direct script access.');
    
    class helper_date_conversion {
      public static function some_function_to_convert($date1, $date2) { } ;
    }
    

    In your view do this:

    helper_date_conversion::some_function_to_convert($date1, $date2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Controller X which basically has 3 actions new, search and result.
In my app, the root view controller acquires information from the internet, parses it,
My controller get datas from database model, and sends them to view. In view
I have some html content stored in a database field. I would like trusted
I have a really simple action in a controller that simply returns a view
I have two action results in my Controller. Overview and About. public ActionResult Overview(int
Should searching be done explicitly in the view, or done in the controller and
Is there any way to send data from controller to view. what I am
I am attempting to use a UIViewController (View Controller) with a table view to
I've passed my model in the View to the Controller with the following jQuery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.