gpt4 book ai didi

c# - 混淆日期格式asp.net mvc

转载 作者:行者123 更新时间:2023-11-30 16:58:19 25 4
gpt4 key购买 nike

我对日期格式感到困惑,在创建模式下,验证器只接受格式 dd-MM-yyyy 而不是 dd.MM.yyyy。在编辑模式下,它向我建议格式 dd.MM.yyyy 无效,所以我每次都必须更改它。

这是日期属性:

[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true)]
public DateTime dateOut
{
get;
set;
}

谁能帮我找出错误在哪里?

谢谢。

最佳答案

格式中的句点指定当前区域性中的日期分隔符。您可以改用文字句点:

[DisplayFormat(DataFormatString = "{0:dd'.'MM'.'yyyy}", ApplyFormatInEditMode = true)]

关于c# - 混淆日期格式asp.net mvc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25420802/

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