Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Date format -> for time AGO
  • How I make a time ago

    Date::time_ago(strtotime("01 January 2012"));

    from database timestamp ??

    I solved it 

    $date = Date::forge($message->created_at)->format("%m/%d/%Y");
    Date::time_ago(strtotime($date))

    thanks anyway


  • HarroHarro
    Accepted Answer
    If your created_at field is a timestamp (which is the default), there is no need to do all this, you can feed it directly into Date::time_ago(), since that wants a timestamp.

    Date::time_ago($message->created_at);

    If it's a MySQL date, you don't need the format() and the strtotime(), since the Date object can give you the timestamp:

    $date = Date::create_from_string($message->created_at, 'mysql');
    Date::time_ago($date->get_timestamp());

  • i tratar de esta manera debido a que en desde el principio yo no estaba trabajando correctamente.

    but you have the reason... thanks again

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion