Php Timestamp To Html 5 Input Type=datetime Element
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 n
Solution 1:
HTML5 Input time
is something like this : 1985-04-12T23:20:50.52
You can do that in PHP like this :
echodate("Y-m-d\TH:i:s");
Output
2012-10-02T19:12:49
HTML with Timestamp
<inputtype="datetime"value="<?phpecho date("Y-m-d\TH:i:s",$timestamp); ?>"/>
Solution 2:
The other examples are both the old way to produce a valid timeStamp format for the TIME element -- the new hotness in php:
<time><?phpecho date(DATE_W3C); ?></time>
That will generate a format like:
"2013-05-19T06:40:08+00:00"
Solution 3:
According to the HTML5 Specification for input type="datetime", it should be as simple as setting the value
attribute.
value="<?phpecho date('c', $timestamp); ?>"
See PHP's date() function for additional formatters.
Solution 4:
Datetime doesn't work for me on chrome, datetime-local allows me to choose date and time from popup.
example
<inputtype="datetime-local"name="xyz"value="<?phpecho date("Y-m-d\TH:i:s",time()); ?>"/>
time() functions is not relevant ,I am using it to make it easy for user to choose from current.. time after or before.
Post a Comment for "Php Timestamp To Html 5 Input Type=datetime Element"