PHP时间戳到HTML 5输入类型=日期时间元素 [英] PHP timestamp to HTML 5 input type=datetime element

查看:33
本文介绍了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输入类型=日期时间元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆