php - how can select timestamp column -


hy have uisng laravel 4
have data this: 2016-02-12 18:32:19
have query this

 echo $result = sourcemanagement::get(array('id', 'created_at', db::raw("date_format(from_unixtime(created_at), '%y') created_at")));     // print_r($result); 

why output :

[      {         "id":1,       "created_at":null    },    {         "id":3,       "created_at":null    },    {         "id":4,       "created_at":null    },    {         "id":7,       "created_at":null    },    {         "id":8,       "created_at":null    },    {         "id":9,       "created_at":null    },    {         "id":10,       "created_at":null    },    {         "id":11,       "created_at":null    },    {         "id":12,       "created_at":null    },    {         "id":13,       "created_at":null    },    {         "id":14,       "created_at":null    } ] 

update query this, might solve problem, per understanding overwriting default column name, thats why getting null, tested below query, working fine.

$result = sourcemanagement::get(array('id', 'created_at', db::raw("date_format(created_at, '%y') created_at_custom")));  

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -