Dav*_*eba 2 php jquery jquery-mobile
我在这里读了很多,并从帖子中找到了很多解决方案.这是我的第一个问题.我希望我做得好.
我使用的是datetime-local输入类型:http:jquerymobile.com/demos/1.2.1/docs/forms/textinputs /
我想从我的数据库预先填充日期时间(使用mysql和php)
问题是我在字段中得到一个值,没有日期时间选择器,或者我没有得到任何值,并且将弹出日期时间选择器.
我似乎无法找到描述如何预填充它的文档.我在俯瞰它?有人可以帮我解决这个问题吗?
〜= - = - = - = - = - =〜
我的测试代码如下.
<div data-role="fieldcontain">
<label for="datetime-l">Datetime local:</label>
<input type="datetime" name="datetime-l" id="datetime-l" value="<?php
$date1 = new Datetime($rrecord->strval('datenote'));
echo $date1->format(DateTime::ISO8601);
?>" />
</div>
<div data-role="fieldcontain">
<label for="datetime-2">Datetime local:</label>
<input type="datetime-local" name="datetime-2" id="datetime-2" value="<?php echo $rrecord->strval('datenote') ?>" />
</div>
Run Code Online (Sandbox Code Playgroud)
第一个字段填充了日期,但触摸时不会弹出日期时间选择器.
请参阅链接屏幕截图 - http://picpaste.com/2013-09-12_21.45.11_1.png
第二个字段为空,但触摸时弹出日期时间选择器.
请参阅链接截图 - http://picpaste.com/2013-09-12_21.45.19.png
这是回调输入的调试代码.他们在第一张截图上显示.
<?php echo "debug datetime prefill from database"; ?>
<?php
echo "<br/>rrecord strval('datenote') = ", $rrecord->strval('datenote');
$date1 = new DateTime($rrecord->strval('datenote'));
echo "<br/> date1 format(DateTime::ISO8601) = ", $date1->format(DateTime::ISO8601);
?>
Run Code Online (Sandbox Code Playgroud)
我能够使用手机输入日期时间.我查看了输出日期时间格式.格式为"Ymd\TH:i".下面我根据PHP格式化了输入日期.
<div data-role="fieldcontain">
<label for="datetime-l">Date:</label>
<input type="datetime-local" name="datetime-l" id="datetime-l" value="<?php
echo date("Y-m-d\TH:i", strtotime($rrecord->strval('datenote')));
?>" />
</div>
Run Code Online (Sandbox Code Playgroud)
这有效.
| 归档时间: |
|
| 查看次数: |
1197 次 |
| 最近记录: |