1

このスクリプトをjQuery easyui dateboxで使用します

<script> 
        function onSelect(date){ 
            $('#result').text(date)       
        } 

</script> 

そして出力は

Selected Date: Tue Jun 11 2013 00:00:00 GMT+0800 (China Standard Time)

それで、出力を作ることは可能ですか:

2013-06-11

作り方は?

value datebox イベントを mysql のクエリに渡したいので

getdata.php

<?php
include 'db.php';

   $created = isset($_POST['text']) ? mysql_real_escape_string($_POST['text']) : '';

$where = "datetime LIKE '$created%'";
$rs = mysql_query("select * from fe1a where " . $where );

$result = array();
while($row = mysql_fetch_object($rs)){
    array_push($array, $row);
}


echo json_encode($result);
?>
4

4 に答える 4

1

作業例: http://jsfiddle.net/Gajotres/xV9BZ/

Javascript:

$('.easyui-datebox').datebox({
    onSelect: function(date){
        alert(date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate());
    }
});

またはあなたの場合は次のようになります:

$('.easyui-datebox').datebox({
    onSelect: function(date){
        $('#result').text(date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate());
    }
});

HTML:

<!DOCTYPE html>
<html>
    <head>
        <title>jQM Complex Demo</title>
        <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
        <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
        <link rel="stylesheet" href="http://www.jeasyui.com/easyui/themes/default/easyui.css" />
        <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
        <script src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>    
    </head>
    <body>
        <input class="easyui-datebox"></input>  
    </body>
</html>   
于 2013-06-21T10:24:38.813 に答える
0

このような何かがうまくいくはずです:

function onSelect(date){ 
                $('#result').text(date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate());       
} 
于 2013-06-21T04:42:38.107 に答える
0

strftime()およびstrtotime( ) を使用して、php でフォーマットを変更することもできます。

$created = isset($_POST['text']) ? strftime('%Y-%m-%d', strtotime(mysql_real_escape_string($_POST['text']))) : '';
于 2014-02-13T12:21:44.040 に答える