php - Modify every value of specified key in array -


I have a database with several rows and columns, which are caught with the PDO.

  $ sql = "timestamp selection from table"; $ Stmt = $ dbh- & gt; Ready ($ sql); $ Result = $ stmt-> carry about; $ Result = $ stmt-> Get All (PDO :: FETCH_ASSOC);   

One of the database columns is timestamp which is a 10 digit unix timestamp. I want to convert this server side to a readable format before sending the browser.

I want it to be formatted, but I know that it should be done on every line and this is where it travels me maybe a foreshop loop? $ result ['timestamp'] = date ('h: i, ljsf of y', $ result ['timestamp']); Directly in DB is very easy to do this, because DB is already saving you to "start looping" on exact same data, to restart the client-side code:

  SELECT DATE_FORMAT (timestamp, '% H:% i, etc ...') from the table    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -