I have a bootstrap datetimepicker which binds to a model in the view. I am binding it to a datetimeoffset variable. When I remove the format field it works but it shows the datetimeoffset variable in the usual datetime format. But with the code below nothing is shown in the textbox.

The following is the bootstrap code:

<script type="text/javascript">
    $(function () {
        $('#dtpStartDateTime').datetimepicker({
            viewMode: 'years',
            format: 'MMMM - DD - YYYY HH:mm Z'
        });
    });
</script>

The following is the razor syntax:

<div class="form-group">
                    <label>Start Date Time</label>
                    <div class="form-group">
                        <div class='input-group date' id='dtpStartDateTime'>
                            @Html.TextBoxFor(x => x.StartDateTime, new { @class = "form-control" })
                            <span class="input-group-addon">
                                <span class="glyphicon glyphicon-calendar">
                                </span>
                            </span>
                        </div>
                    </div>
                </div>

Related posts

Recent Viewed