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 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛