Convert timestamp to date in Laravel? -
how can return database rows timestamp converted date (d-m-y h:i), using all() method?
it's not created_at or updated_at column, it's custom attribute, call birthday if wish.
in case, need convert date within query, if mysql being used database may use raw query this:
// assumed my_birthday 1255033470 $raw = db::raw("date_format(from_unixtime(my_birthday),'%b %d, %y %l:%i %p') dob"); $result = model::get(array('id', 'username', $raw)); you may write within single line:
$result = model::get(array('id', 'username', db::raw("...")));
Comments
Post a Comment