Friday, November 10, 2006
Python (IronPython) time to .NET C# DateTime format
Today i was trying to use Python (IronPython) time format in .NET, how their was no straight forward way to consume the same in C#.
The trick was to convert the Python time format into .NET format
Here is the code, which i have used:
1: i_tmp = os.path.getatime(path)
2: t_tmp = localtime(i_tmp)
3: tstamp = strftime("%m/%d/%Y %H:%M:%S", t_tmp)
Now you can directly use the same in C#
1: //Sample datetime format from python
2: string str = "11/05/2006 23:54:46";
3: DateTime dt2 = Convert.ToDateTime(str);