Search code examples
phpkohanakohana-3.2

PHP/Kohana - Converting time to different format


In my kohana app, I need to convert the time retrieved from the database into a format like 45 seconds ago, 1 minute ago, etc. What is the best place to do it? Can I override any methods in the Model so that the method automatically converts the time into the desired format before returning into the controller?


Solution

  • The Date::span() and Date::fuzzy_span() methods do it.

    Please do some research before asking questions. It took me 30 seconds to find them... Google "kohana date format", click the first link, and look through the methods.