Literal four = new Literal();
string timeanddate;
timeanddate = DateTime.UtcNow.ToString();
DateTime dt = new DateTime();
DateTime dt_calc = new DateTime();
dt = Convert.ToDateTime(timeanddate);
dt_calc = dt.AddHours(3);
four.Text = "3hr added and this gives>> " + dt_calc.ToString();
form1.Controls.Add(four);
这段文本涉及到 AM PM 时间格式,但我希望使用 24 小时制。
CurrentCulture
和DateTimeFormatInfo
。 - Dan Tao