dongxi4335 2013-09-13 02:24
浏览 106
已采纳

将日期时间值从php填充到Jquery Moble文本输入datetime-local

I have read alot here, and figured out a lot of solutions from the posts. This is my first question. I hope I do well.

I am using the datetime-local input type from: http: jquerymobile.com /demos/ 1.2.1 /docs /forms /textinputs/

I want to prefill it with the datetime from my database (using mysql and php)

Problem is I get a value in the field and no datetime picker or I get no value and the datetime picker will popup.

1. I can't seem to find the documentation that describes how to prefill it. I am overlooking it? 2. Can someone help me resolve this?

~=-=-=-=-=-=~

My test code is as follows.

        <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>

The first field is filled with a date, but no datetime picker will pop up when touching it.

see linked screenshot -- http://picpaste.com/2013-09-12_21.45.11_1.png

The second field is empty, but a datetime picker pops up when touched.

see linked screenshot -- http://picpaste.com/2013-09-12_21.45.19.png

This is the debug code that echos the inputs. They show on the first screenshot.

    <?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);
    ?>
  • 写回答

2条回答 默认 最新

  • dtll2016 2013-09-16 14:50
    关注

    I was able to input a datetime using the phone. I looked at the output datetime format. The format was "Y-m-d\TH:i". Below I formatted the input date accordingly from 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>
    

    This works.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Jenkins+k8s部署slave节点offline
  • ¥15 微信小游戏反编译后,出现找不到分包的情况
  • ¥15 如何实现从tello无人机上获取实时传输的视频流,然后将获取的视频通过yolov5进行检测
  • ¥15 WPF使用Canvas绘制矢量图问题
  • ¥15 用三极管设计一个单管共射放大电路
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题