我遇到了问题,因为错误消息表明已超出数据限制。
我尝试将datatime的格式更改为许多这样的格式,最后我找到了它。
<div class="form-group-inner">
<div class="row">
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
<label class="login2 pull-right pull-right-pro">Start Time</label>
</div>
<div class="col-lg-9 col-md-9 col-sm-9 col-xs-12">
<input type="time" id="Timefrom" name="Timefrom"
min="6:00" max="20:00">
</div>
</div>
</div>
<div class="form-group-inner">
<div class="row">
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
<label class="login2 pull-right pull-right-pro">Startdate</label>
</div>
<div class="col-lg-9 col-md-9 col-sm-9 col-xs-12">
<input type="date" id="Startdate" name="Startdate"
value="2019-06-29" min="2019-01-01" max="2019-12-31">
</div>
</div>
</div>
</div>
if (!String.IsNullOrEmpty(fc["Timefrom"]) && !String.IsNullOrEmpty(fc["Startdate"]))
{
string[] rdate = fc["Startdate"].Split('-');
model.Timefrom = Convert.ToDateTime(rdate[2] + "-" + rdate[1] + "-" + rdate[0] + " " + fc["Timefrom"])
}
答案 0 :(得分:0)
C#不支持日期时间格式“ dd-mm-yy hh:mm”。请按照以下步骤重新编写代码
if (!String.IsNullOrEmpty(fc["Timefrom"]) && !String.IsNullOrEmpty(fc["Startdate"]))
{
string[] rdate = fc["Startdate"].Split('-');
model.Timefrom = Convert.ToDateTime(rdate[0] + "-" + rdate[1] + "-" + rdate[2] + " " + fc["Timefrom"])
}