c# - 客户日期开始时间

标签 c# datetime datetimepicker

当我的应用程序启动时,我有一个用于开始时间和结束时间的日期时间选择器。

dvSubmittedDateBegin.Format = DateTimePickerFormat.Custom;
dvSubmittedDateBegin.CustomFormat = "MMM dd yyyy  - hh mm tt";

一切正常。但是,我被要求在凌晨 5 点开始默认设置。

我创建了一个新的日期时间并分配了 dvSubmittedDateBegin.Value - dt;

但是我想我必须指定每个 int 的新日期时间?

DateTime dt = new DateTime(2015, 6, 24, 05, 00, 0);

明天 6 月 25 日会发生什么?不确定如何解决这个问题。

最佳答案

喜欢怎么样;

DateTime dt = DateTime.Today + TimeSpan.FromHours(5);

或更简单

DateTime dt = DateTime.Today.AddHours(5);

您将通过 DateTime.Today 获得从午夜开始的当前日期并且您将向其添加 5 小时,即当天凌晨 5 点。

关于c# - 客户日期开始时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31027295/

相关文章:

Android 日期/时间轮选择器

jquery - 日期时间选择器 - 设置打开日期和时间

c# - 只读日期时间选择器文本框

java - 解析带有时区标识符的未知日期时间字符串

c# - 如何禁用 TabControl 中的选项卡?

c# - Xamarin.forms 中的录音

c# - 循环推送值列表的 Observable

python - 将 Matplotlib 的日期转换为浮点天数格式

mysql - 毫秒还是日期类型?

c# - 为什么 IE 不能将我的输出识别为 XML?