I want to assign value to datetimepicker, but isn't work anymore.

I tried, but the results were not as expected.

Jquery to assign value :

$('#iTTDateOpen').data('datetimepicker').setLocalDate(new Date(2019, 6, 2, 10, 55));

HTML Code :

<div class="form-group">
<label class="col-md-3 control-label">TT Date Open</label>
<div class="col-md-7">
<input type="text" id="iTTDateOpen" class="form-control txt filter-time" placeholder="Trouble Ticket Date Open" onkeydown="return false" required>
</div>
</div>

I expected the output is 2019-06-02 10:55, but the actual output is /Date(1559001300000)/

2 Answers

0
Diogo Capela On

Maybe something like this?

$('#iTTDateOpen').html(new Date(2019, 6, 2, 10, 55));
0
Kgs. Azzam Nizar On

Problem was solved.

On your database, convert the value using varchar :

convert(VARCHAR, trx.TroubleTicketDateOpen,20)

On your HTML, add properties like :

<input type="text" id="iTTDateOpen" class="form-control txt filter-time" data-date-format="yyyy-mm-dd hh:ii:ss" placeholder="Trouble Ticket Date Open" onkeydown="return false" required>

On your JavaScript :

$('#iTTDateOpen').val(dt.TroubleTicketDateOpen);