[Resolved] Bootstrap datetimepicker date set to ’31/10/1899 00:00′
Hi,
In this article, I’m going to show how I faced that issue and make it work. I was working on a customer project and while implementing the bootstrap datetimepicker If found datetimepicker date was showing some weird date ending with the year 1899 instead of a current year.
So I did some research and found a solution for this issue. It is a very quick fix. Please find below my code which is working with asp.net MVC.
div class='input-group date' @Html.EditorFor(model => model.ValidFrom, new { htmlAttributes = new { @class = "form-control m-input datetimepicker" } }) <span class="input-group-addon"> <i class="la la-calendar"></i> </span> </div>
I have added the script code to below section:
<script src="~/assets/demo/default/custom/components/forms/widgets/bootstrap-datetimepicker.js" type="text/javascript">></script> <script type="text/javascript"> $(document).ready(function () { $('.datetimepicker').datetimepicker({ format: "dd-mm-yyyy hh:ii:00P", autoclose: true }); }); </script>
I just changed the format and removed all the extra spaces to make it working dd-mm-yyyy hh:ii:00P.
I hope it will save your valuable time and If it won’t work then feel free to hire me.
Cheers!