Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a class in Models folder of an asp.net project which has a field with datatype Datetime. Now I want the date and time parts of this field to be populated through a Create.cshtml page.

The field in Models folder is:

[Display(Name = "Event Date and Time")]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public DateTime? EventDate { get; set; }

The Create.cshtml page has this code for inputting EventDate:

        <div class="editor-label">
            @Html.LabelFor(model => model.EventDate)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.EventDate)
            @Html.ValidationMessageFor(model => model.EventDate)
        </div>

The input-box which gets displayed on Create page only accepts date. I am thinking that this is because of DataFormatString = "{0:yyyy-MM-dd}" . Can anyone tell me what should I change this to, so that I can input both date and time from that box?

share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.