[英]Returning Just Time (in Military) from DB in ASP.NET/VB.NET
I'm saving military time into the database. 我将军事时间节省在数据库中。 Then I need to pull this data back out of the database.
然后我需要将这些数据从数据库中拉回来。 To get just the time without the date I can do this:
为了得到没有约会的时间,我可以这样做:
String.Format("{0:T}", pullsaved.First.timeValue)
But this returns a six digit time, eg 100000 (HHmmss). 但这会返回六位数的时间,例如100000(HHmmss)。 But I want it to return just HHmm (1000).
但我希望它只返回HHmm(1000)。 I tried the following, but it didn't work...any ideas?
我尝试了以下,但它没有用......任何想法?
DateTime.ParseExact(String.Format("{0:T}", pullsaved.First.timeValue), "HHmm", CultureInfo.InvariantCulture)
String.Format("{0:HHmm}", pullsaved.First.timeValue)
要么
pullsaved.First.timeValue.ToString("HHmm")
Easiest way is: 最简单的方法是:
DateTime dt = someDate;
string formattedDate = dt.ToString("HHmm");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.