以格式js检索日期

时间:2017-02-03 08:46:51

标签: javascript php

我有这样的代码:

if(substr($field, -7)=="StartDate"){ 
    // If change start date
    $end = str_replace('StartDate', 'EndDate', $field);
    if (property_exists($this, $end)) {
        echo "if(!this.value) {";
            echo "  var end = dijit.byId('$end').get('value');"; // $end will be replaced by value as enclosed by "
            echo " if(end){";
                echo "  var dtStart = $this.value;"; // => I need to retrive the date of $this in format js
                echo "  end.constraints.min=dtSatrt;";
            echo " }";
        echo "}";
    }
}

对于echo " var dtStart = $this.value;"; // => I need to retrive the date of $this in format js这一行,你能帮帮我吗?谢谢!!

1 个答案:

答案 0 :(得分:0)

只是回显函数周围的标签,当它以html输出时,脚本将运行。

echo"<script>var dtStart = " . $this.value . "</script>";