你好,我實際上是在我的c#應用程序中使用datepicker。爲了拿起日期和時間,我已經使用中的屬性如下設置:C#日期選擇器24小時日期和時間
format = custom
customformat = dd MM yyyy hh mm ss
能正常工作,但只顯示小時分鐘,取值範圍爲1〜12,我希望能夠代表0小時23.有什麼建議?提前致謝。
你好,我實際上是在我的c#應用程序中使用datepicker。爲了拿起日期和時間,我已經使用中的屬性如下設置:C#日期選擇器24小時日期和時間
format = custom
customformat = dd MM yyyy hh mm ss
能正常工作,但只顯示小時分鐘,取值範圍爲1〜12,我希望能夠代表0小時23.有什麼建議?提前致謝。
嘗試請HH代替HH:
格式=定製
customformat =年月日HH毫米SS
嘗試使用:
customformat = dd MM yyyy HH mm ss
即使用大寫字母H而不是小寫字母h。
您可以根據您的要求設置自定義格式dd MM yyyy HH mm ss
。您可以檢查here的自定義格式。同樣,您可以使用DateTime.TryParseExact()將DateTime
的值讀取爲:
string strDateStarted = datetimepicker1.Value.Tostring();
DateTime datDateStarted;
DateTime.TryParseExact(strDateStarted, new string[] { "dd MM yyyy HH mm ss" }, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out datDateStarted);
Console.WriteLine(datDateStarted);