Use DateTime.ParseExact(). Something like:
string date = "20100102";
DateTime datetime = DateTime.ParseExact(date, "yyyyMMdd", CultureInfo.InvariantCulture);
More Related Contents:
- How do I calculate someone’s age based on a DateTime type birthday?
- DateTime vs DateTimeOffset
- Parse DateTime with time zone of form PST/CEST/UTC/etc
- Algorithm to detect overlapping periods [duplicate]
- C# DateTime.Now precision
- How to get difference between two dates in Year/Month/Week/Day?
- format date in c#
- How do I get the last day of a month?
- What does “DateTime?” mean in C#?
- Measuring code execution time
- Environment.TickCount vs DateTime.Now
- Why DateTime.AddHours doesn’t seem to work?
- How to convert Javascript datetime to C# datetime?
- How to find the 3rd Friday in a month with C#?
- Parse C# string to DateTime
- DateTime ToString issue with formatting months with “mm” specifier
- why does DateTime.ToString(“dd/MM/yyyy”) give me dd-MM-yyyy?
- How to ensure a timestamp is always unique?
- How can I format DateTime to web UTC format?
- datetime to string with time zone
- How frequent is DateTime.Now updated ? or is there a more precise API to get the current time?
- How to parse and generate DateTime objects in ISO 8601 format
- DateTime conversion from string C#
- DateTime.Parse(“2012-09-30T23:00:00.0000000Z”) always converts to DateTimeKind.Local
- Getting the first and last day of a month, using a given DateTime object
- Days, hours, minutes, seconds between two dates
- How to check if a DateTime occurs today?
- Convert DateTime to long and also the other way around
- LINQ Query to Convert string to datetime
- .NET DateTime to SqlDateTime Conversion