Tuesday, October 27, 2009

C# - example of time string formatting

Below is two simple example of how to use C# to display date/time in different format:

[Present Time]
strNow = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

[TimeStamp of File]
FileInfo fi = new FileInfo(strPath);
fi.LastWriteTime.ToString("yyyyMMddHHmmss");

No comments: