PHP timestamp to HTML 5 input type=datetime element(PHP时间戳到HTML 5输入类型=日期时间元素)
问题描述
我在 PHP 中有一个 unix 时间戳 (int).我想在 HTML5 日期时间输入元素中以一种很好的方式显示这个值.我希望能够让用户以一种漂亮的方式看到这个值,并对其进行编辑.有什么好的方法可以做到这一点,还是我在自欺欺人,我将不得不对大量的字符串操作大惊小怪?
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
是这样的:1985-04-12T23:20:50.52
你可以像这样在 PHP 中做到这一点:
You can do that in PHP like this :
echo date("Y-m-dTH:i:s");
输出
2012-10-02T19:12:49
带有时间戳的 HTML
HTML with Timestamp
<input type="datetime" value="<?php echo date("Y-m-dTH:i:s",$timestamp); ?>"/>
这篇关于PHP时间戳到HTML 5输入类型=日期时间元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP时间戳到HTML 5输入类型=日期时间元素


- 如何定位 php.ini 文件 (xampp) 2022-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- Laravel 仓库 2022-01-01