I have a date string as "9 July 1pm CET" I want to convert that to proper datetime object with my system timezone that is IST.
How can i parse it to proper datetime object?
https://docs.microsoft.com/en-us/dotnet/api/system.datetime.parse?view=netframework-4.8
public class Example
{
public static void Main()
{
string[] dateStrings = {"2008-05-01T07:34:42-5:00",
"2008-05-01 7:34:42Z",
"Thu, 01 May 2008 07:34:42 GMT"};
foreach (string dateString in dateStrings)
{
DateTime convertedDate = DateTime.Parse(dateString);
Console.WriteLine($"Converted {dateString} to {convertedDate.Kind} time {convertedDate}");
}
}
}
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.