PHP时间戳记到HTML 5输入type = datetime元素 [英] PHP timestamp to HTML 5 input type=datetime element
本文介绍了PHP时间戳记到HTML 5输入type = datetime元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在PHP中有一个unix时间戳(int).我想以很好的方式在HTML5 datetime输入元素中显示此值.我希望能够以一种很好的表现方式让用户看到该值,并对其进行编辑.有什么不错的方法吗?还是我在自欺欺人,不得不对很多字符串操作大惊小怪?
I have a unix timestamp (int) in PHP. I want to display this value in a nice manner in the HTML5 datetime input element. I would like to be able to have users see this value in a nice presentable manner, as well as edit it. Is there any nice way of doing this, or am I fooling myself and I am going to have to fuss around with lots of string manipulation?
推荐答案
HTML5 Input time
类似于以下内容:您可以像这样在PHP中做到这一点:
You can do that in PHP like this :
echo date("Y-m-d\TH:i:s");
输出
2012-10-02T19:12:49
带有时间戳的HTML
HTML with Timestamp
<input type="datetime" value="<?php echo date("Y-m-d\TH:i:s",$timestamp); ?>"/>
这篇关于PHP时间戳记到HTML 5输入type = datetime元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文