My datetime string looks like this
19430403000000-0400
But I only care about the values before the dash (i know its UTC offset, but I don't require that offset value)
So I want to use DateTime.TryParseExact if possible since I have a class that already implements it where the user passes the datetime format as string
So for this I want something like
"yyyyMMddhhmmss-####"
where the user can ignore parts of the string format
Is that possible?
I think I still have to specify the entire format, I just have to use DateTimeOffset instead of DateTime. Seems to parse it alright.
string date8 = "19430403000000-0400";
DateTimeOffset result2;
bool parsed = DateTimeOffset.TryParseExact(date8, "yyyyMMddhhmmss zzzz", CultureInfo.InvariantCulture,
DateTimeStyles.AllowWhiteSpaces,
out result2);
string str = "19430403000000-0400";
string output = str.Split("-")[0];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.