Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Fuel\Core\Date vs \DateTime
  • I like Date class from Fuel, but it is not enough some features, as I see. Several useful features that exists in standard PHP class DateTime are may be very useful to add them into Fuel Date. Like this:

    $startDate = new \Date('2015-08-01');
    $endDate = new \Date('2015-08-31');

    $offset = $startDate->diff($endDate); // this first

    $startDate->modify('-1 day') // this second

    $startDate->sub($offset) // this third

    What about?
  • We wrote an entire new Date class, that was interface compatible with PHP's DateTime class (so you could also use it in any function or method that uses DateTimeInterface as a typehint. See https://github.com/fuelphp/common/blob/master/src/Date.php.

    Which worked fine, until some moron decided that for PHP 5.5, your own classes may no longer implement DateTimeInterface, see https://twitter.com/WanWizard/status/565873929659887616. Was reported to PHP internals, but as usual, only silence...

    So we're back to the drawing board on this one.

    In the meantime, you can include fuelphp/common using composer, and use \FuelPHP\Common\Date in your projects, the code has been stable for a while. It has all DateTime features, plus the v1 Date methods like create_from_string(), etc.
  • Thank you for comment. It's really sad story...
    Ok, I'll try to follow your advice.

Howdy, Stranger!

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

In this Discussion

  • bvn September 2015
  • Harro September 2015