If I remember correctly, the code for getting 24h clock from DateTime.ToString()
is HH
.
delDate = dm.ToString("MM-dd-yyyy HH:mm");
質問
I have getting two value from date and time control and after that i use add minutes in that
Example - datePickerReadyDate.Text
i have value 05/07/2014
and TimePickerReadyTime.Text
have value is 10:05
And i am adding minutes in time. i am getting result 05/07/2014 02:05 PM
but i want the result as 05/07/2014 14:05
. Below is my code .
int Time = 240;
DateTime _readyTime = Convert.ToDateTime(datePickerReadyDate.Text + " " + TimePickerReadyTime.Text);
var dm = _readyTime.AddMinutes(Time);
delDate = dm.ToString("MM-dd-yyyy hh:mm");
How can i do this . Thanks in advance .
解決
If I remember correctly, the code for getting 24h clock from DateTime.ToString()
is HH
.
delDate = dm.ToString("MM-dd-yyyy HH:mm");
他のヒント
Use HH instead of hh:
delDate = dm.ToString("MM-dd-yyyy HH:mm");
See http://msdn.microsoft.com/en-us/library/zdtaw1bw(v=vs.110).aspx
Write down HH instead of hh as shown below :-
delDate = dm.ToString("MM-dd-yyyy HH:mm");
hh--> The hour, using a 12-hour clock from 01 to 12.
HH--> The hour, using a 24-hour clock from 00 to 23.
delDate = dm.ToString("MM-dd-yyyy HH:mm");