Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
DB class and MySQL functions / formatting MYSQL timestamp
  • How can I do this using the DB class :
    SELECT DATE_FORMAT(timestampfield, '%Y-%m-%d %H:%i:%s') AS dtime FROM
    table i was thinking something along these lines : DB::select('id',array(DATE_FORMAT('timestamp', '%Y-%m-%d'),'timestamp')) the idea is to return a formatted date as opposed to the MYSQL timestamp ( Y-M-D h:m:s) perhaps if possible, you can suggest a better way to deal with formatting MySQL timestamp thank you for your help
  • If I'm not mistaken:
    DB::select(array(DB::expr('DATE_FORMAT(timestampfield, "%Y-%m-%d %H:%i:%s")'), 'dtime'));
    

    DB::expr() wraps the string in a Database_Expression object that prevents it from being quoted. It's put into an array with 'dtime' as the second value that will make 'dtime' the alias for the column.
  • Super! worked like a charm. thank you again Jelmer !

Howdy, Stranger!

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

In this Discussion