Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Date::forge()->create_from_string
  • Hi,

    may be, it's a simple question ... but I can't answer it to myself.

    This Code works locally on my Windows-Plattform:

    Date::forge()->create_from_string("-1 month")->format("%Y-%m")

    On our Webserver an Exception is thrown:

    UnexpectedValueException
    ('Input was not recognized by pattern.');


    I know about about strtotime() and strptime( and Windows and Linux/Unix.

    Is there any way to determine a date one month ago with Date::forge() working on both plattforms?

    Thank you and gerretings form Germany.
  • Your webserver is Linux? In general, the restrictions are on the Windows platform, anything that works on Windows should work without problems on Linux.

    Having said that, the first parameter of create_from_string() should be a valid date/datetime string, and "-1 month" is clearly not a valid date. The fact that it works on Windows is because of the workaround we had to implement to bypass the lack of support for strptime. So, bottomline, you're using it in a way that is not supported.

    If you want relative time, you need to convert it to a timestamp first, and pass that:

    \Date::forge(strtotime("-1 month"))->format("%Y-%m");

Howdy, Stranger!

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

In this Discussion