我希望得到日期和日期时间的区别并将其显示为经过时间,例如: 4days 7hr 8min 3sec ..尝试了这个但只给了我日期部分的区别:
THis is in my template:
<form is="iron-form" id="formPost" method="post" action="/">
<paper-input name="email" id="email" label="Email Address" value="{{email}}"required></paper-input>
</br>
<paper-button type="submit" name="submit" raised on-click="buttonClick">Notify Me!</paper-button>
</form>
<iron-ajax
contentType: "application/json"
headers='{"Content-Type": "application/json;charset=utf-8"}'
id="landingPageForm"
url="https://mandrillapp.com/api/1.0/messages/send.json"
method="POST"
params='{"key":"2342sdfsdf","message":""from_email":"example@domain.com",
"to":[{"email":"recipient@domain.com"}],
"subject": "Subject line",
"text": "text in the message""}'
handle-as="json"
>
</iron-ajax>
答案 0 :(得分:2)
您可以使用TIMESTAMPDIFF()
功能和CONCAT()
来获取所需的格式:
SELECT CONCAT(TIMESTAMPDIFF(DAYS, s.date, b.creation_date), 'days ',
MOD(TIMESTAMPDIFF(HOUR, s.date, b.creation_date), 24), 'hr ',
MOD(TIMESTAMPDIFF(MINUTE, s.date, b.creation_date), 60), 'min ',
MOD(TIMESTAMPDIFF(SECOND, s.date, b.creation_date), 60), 'sec') AS dated
<强>输出:强>
4days 7hr 8min 3sec