A simple question, how to convert the timestamp to Y-M-D in this case?

WBOY
Release: 2016-10-18 08:56:00
Original
1093 people have browsed it

A simple question, how to convert the timestamp to Y-M-D in this case?

The above is the output timestamp in AJAX. I don’t know how to do it, so I tried to convert it in PHP

A simple question, how to convert the timestamp to Y-M-D in this case?

A simple question, how to convert the timestamp to Y-M-D in this case?

But why can’t I rotate like this in the model or C? When output, this array becomes this field, and other fields are lost

I found out from the answer of an expert above that you can use the mysql statement to convert the addtime into time format in the linked list. But in TP, if you add that kind of conversion statement after the field field, will an error be reported? Does anyone know how to write without getting an error?

I know I am a bit mentally retarded with this question, so I humbly seek advice from an expert, thank you

Reply content:

A simple question, how to convert the timestamp to Y-M-D in this case?

The above is the output timestamp in AJAX. I don’t know how to do it, so I tried to convert it in PHP

A simple question, how to convert the timestamp to Y-M-D in this case?

A simple question, how to convert the timestamp to Y-M-D in this case?

But why can’t I rotate like this in the model or C? When output, this array becomes this field, and other fields are lost

I found out from the answer of an expert above that you can use the mysql statement to convert the addtime into time format in the linked list. But in TP, if you add that kind of conversion statement after the field field, will an error be reported? Does anyone know how to write without getting an error?

I know I am a bit mentally retarded with this question, so I humbly seek advice from an expert, thank you

<code>// zero padding, 补0
function zp(n){ return n<10?['0',n].join(''):n; }
// ts为13位的时间戮(ms), 如果是秒,乖1000
function ts_date(ts, d){
    d = new Date(+ts); // +号, 若为字符串转为数字
    return [d.getFullYear(), zp(d.getMonth()+1), zp(d.getDate())].join("-")+" "+[zp(d.getHours()), zp(d.getMinutes()), zp(d.getSeconds())].join(":");
}</code>
Copy after login
<code>+ ts_date(v.addtime) + '</span>';</code>
Copy after login

$pinluns is a two-dimensional array. You can print it and take a look. To format the timestamp, you can loop $pinluns to do it, or you can use MySQL data formatting when checking the database without using PHP. Formatted.

It is recommended to turn the handlebar on the front.

But this won’t work. The array queried by select is a two-dimensional array, and you need to reassemble the data.

<code>->find()才是查询一条数据;
如果->select()   那就是$pinluns[0]['addtime'];</code>
Copy after login

The selected result is a two-dimensional array. You need to use foreach to traverse the array and add addtime

moment

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template