将日期时间值从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);
    ?>

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.

$(document).ready(function() {
$("#datetime-1").val(<?php YOUR CODE ?>);
$("#datetime-2").val(<?php YOUR CODE ?>);
});

Its a bit hacky but it should work, just make sure the format of the date is what jq mobile is expecting.