Hack Forums
[C#] DateTime format - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] DateTime format (/showthread.php?tid=4877259)



DateTime format - SIM-1809171 - Jun 23, 2015

Hey

I'm using -

Code
FileInfo info = new FileInfo(Environment.CurrentDirectory + "/temp" + folder + "/" + filename);
            DateTime datetimelocal = info.LastAccessTime;
            string datetimedownloadtemp = dirlist[i].Substring(43, 12);
            DateTime datetimedownload = Convert.ToDateTime(datetimedownloadtemp);
            Console.WriteLine(datetimedownload);
            Console.WriteLine(datetimedownloadtemp);
            Console.WriteLine(datetimelocal);

along with some FTP shit in order to compare two datetime stanps. However, the FTP class returns the datetime in string format. When I try convert, it always gives 23:00:00 as the time. (or something similar)

Heres is the output -

[Image: 9fab702dde87c08618cc29526e78c980.png]

As you can see, its getting the date correct, but the time is all wrong.

Cheers
What can I do to sort this?


* - Only3 - Jun 23, 2015

u get the LastAccessTime not the current


* - SIM-1809171 - Jun 23, 2015

(Jun 23, 2015 05:06 AM)Only3 Wrote:  u get the LastAccessTime not the current

That's not the issue. I've tried with both. The issue is the timeStamp of the one. It's not correct because of the format.


* - phrootoo - Jun 23, 2015

try ParseExact. You probably have an issue with the culture.

https://msdn.microsoft.com/en-us/library/w2sa9yss(v=vs.110).aspx