开发者

how to get dates from text in c#

开发者 https://www.devze.com 2023-02-08 01:14 出处:网络
From a document I want to find and get the dates, and the date will be in a different format in each document. How do I a开发者_运维百科chieve that in C#?You should rather have a look at using DateTim

From a document I want to find and get the dates, and the date will be in a different format in each document. How do I a开发者_运维百科chieve that in C#?


You should rather have a look at using DateTime.TryParse Method or DateTime.TryParseExact Method

DateTime.TryParse Method Converts the specified string representation of a date and time to its DateTime equivalent and returns a value that indicates whether the conversion succeeded.

DateTime.TryParseExact Method Converts the specified string representation of a date and time to its DateTime equivalent using the specified array of formats, culture-specific format information, and style. The format of the string representation must match at least one of the specified formats exactly. The method returns a value that indicates whether the conversion succeeded.


Use DateTime.ParseExact(string, format) to create a DateTime from a formatted string.

Check out http://www.codeproject.com/KB/cs/String2DateTime.aspx for more details.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号