我如何设置输入类型'datetime-local'的值? [英] How can i set a value for the input type 'datetime-local'?

查看:2121
本文介绍了我如何设置输入类型'datetime-local'的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过这个:

 < input type =datetime-localvalue =<?php echo $行['时间'];?> class =datename =startREQUIRED> 

我怎样才能设定这个输入字段的值与数据库中的数据?


它不起作用!!
我也需要编辑它。
或者我应该使用其他类型的输入吗?
$ row ['Time'];是来自数据库的!

解决方案

我不知道 $ row ['Time '] ,但应如下所示:

定义


一个在 RFC 3339 中定义的有效日期时间,带这些
附加限定条件:


  • 日期/时间语法中的文字字母T和Z必须始终为大写形式
  • date-fullear制作替代地定义为四个或更多个数字表示一个大于0的数字

  • $ b >
  • 1990-12-31T23:59:60Z

  • 1996-12-19T16:39:57-08:00






解决方案

要在PHP中创建 RFC 3339 格式,您可以使用:

  echo date ('Ymd'\\TH:我:sP',$ row ['时间]); 

或以其他方式:

<$ p $回声日期(c,strtotime($ row ['Time']));






在您的代码



所以在你的代码里它看起来如下:

 < ; input type =datetime-localvalue =<?php echo date('Ymd'\\TH:i:sP',$ row ['Time']);?> class =datename =startREQUIRED> 

 < input type =datetime-localvalue =<?php echo date(c,strtotime($ row ['Time']));?> class =datename =startREQUIRED> 






手动 p>

更多信息可以在 here

I tried this:

<input type="datetime-local"  value="<?php echo $row['Time']; ?>" class="date" name="start" REQUIRED>

How can i set the value of this input field with the data from the database?
It doesn't work!!
I need to make it possible to edit too.
Or should I use another type of input? $row['Time']; is from the database!

解决方案

I don't know exacly what is in $row['Time'] but it should be as follows:

Definition

A valid date-time as defined in RFC 3339 with these additional qualifications:

  • the literal letters T and Z in the date/time syntax must always be uppercase
  • the date-fullyear production is instead defined as four or more digits representing a number greater than 0

Examples

  • 1990-12-31T23:59:60Z
  • 1996-12-19T16:39:57-08:00


Solution

To create RFC 3339 format in PHP you can use:

echo date('Y-m-d\TH:i:sP', $row['Time']);

or in another way:

echo date("c", strtotime($row['Time']));  


In your code

So in your code it would look as follows:

<input type="datetime-local"  value="<?php echo date('Y-m-d\TH:i:sP', $row['Time']); ?>" class="date" name="start" REQUIRED>

or

<input type="datetime-local"  value="<?php echo date("c", strtotime($row['Time'])); ?>" class="date" name="start" REQUIRED>


Manual

More informations can be found here

这篇关于我如何设置输入类型'datetime-local'的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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