Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Fuel and SQL date handling
  • Hi

    I was wonderering why the fuel dev team prefer to implement timestamp for date storage in database, instead of the date objects ?

    It's not a problem, just wondering.
  • You don't mention your database, but in most ones you can not store objects (and if you can it's usually if a format that doesn't allow you to query it).

    In the case of MySQL (as an example), you can only store strings, which either represent an integer (in the case of a timestamp) or a MySQL date string.

    So I'm not sure where you want to go with this question. If you refer to Fuel Date objects, the ORM supports those throught the typing observer, which can convert to and from a Date object based on date information in the database.
  • Yeah, I was talking about MYSQL date string. And assumed the default database for fuel is MYSQL...

    It's just interest, I want to know why you chosen to use timestamp . But now i understand, different SQL engine have different date managment, so the timestamp is the only way to stay general, right ?
  • HarroHarro
    Accepted Answer
    Apart from that, I prefer the timestamp.

    It doesn't have to be user readable, it has to be machine readable. A MySQL date string is useless in most operations unless you convert it first.

    Also, a timestamp is (or should be) always in GMT. So you avoid al kinds of nasty timezone issues. With a MySQL date string, you don't know unless you know what the timezone is the server runs in.
  • Yeah, got it. Thanks.

Howdy, Stranger!

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

In this Discussion