gpt4 book ai didi

asp.net-mvc - Kendo DateTimePicker 设置当前小时 12 :00 AM instead of DateTime. Now

转载 作者:行者123 更新时间:2023-12-01 16:54:18 24 4
gpt4 key购买 nike

DateTimePicker / Basic usage上所示,我在下面使用的示例在按下 DateTimePicker 页脚处的链接时设置当前小时 12:00 AM,而不是 DateTime.Now。如何解决?

@(Html.Kendo().DateTimePickerFor(m => m.VisitDate)
.Animation(true)
.Format("dd/MM/yyyy HH:mm")
.TimeFormat("HH:mm")
.Min(new DateTime(1900, 1, 1))
.Max(new DateTime(2099, 12, 31))
.Footer(true)
.Value(DateTime.Now)
)

之前:
Before
之后:
After

链接插入午夜 - 但这感觉不对。

如何让它插入当前时间?


更新:这是我在上一步中使用的 DateTimePicker 和 javascript 方法:

@{
ViewBag.Title = "Create";
Layout = "~/Views/Shared/_Layout.cshtml";
var today = DateTime.Now.ToString("dd/MM/yyyy 00:00",
new System.Globalization.CultureInfo("en-US"));
}


@(Html.Kendo().DateTimePicker()
.Name("datetimer")
.Animation(true)
//.Culture("en-US")
.TimeFormat("HH:mm")
.Min(new DateTime(1900, 1, 1))
.Max(new DateTime(2099, 12, 31))
.Value(DateTime.Now)
.Format("dd/MM/yyyy HH:mm")
.Events(e => e.Change("datetimepicker_change"))
)


<script>
function datetimepicker_change() {
// I use this method so that when selecting another day except from today,
// the hour should be 00:00. But it does not make sense whether or not using it
if ($('#datetimer').val() != '@today') {
return;
}


if ($('#datetimer').val() == '@today') {
$('#datetimer').val('@DateTime.Now.ToString("dd/MM/yyyy HH:mm")');
}
}
</script>

最佳答案

您好,这就是我处理这个问题的方式;

var today = DateTime.Now.ToString("dd/MM/yyyy 00:00", new System.Globalization.CultureInfo("en-US"));

@(Html.Kendo().DateTimePicker()
.Name("test")
.Animation(true)
.TimeFormat("HH:mm")
.Min(new DateTime(1900, 1, 1))
.Max(new DateTime(2099, 12, 31))
.Value(DateTime.Now)
.Format("dd/MM/yyyy HH:mm")
.Events(e => e.Change("datetimepicker_change"))
)

<script>
function datetimepicker_change() {
if ($('#test').val() == '@today') {
$('#test').val('@DateTime.Now');
}
}
</script>

full code via VS 2015

结果:youtube

关于asp.net-mvc - Kendo DateTimePicker 设置当前小时 12 :00 AM instead of DateTime. Now,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34333504/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com