Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Jeff Atwood had a few things to say about this issue in <a href="http://blog.codinghorror.com/determining-build-date-the-hard-way/" rel="noreferrer">Determining Build Date the hard way</a>.</p> <p>The most reliable method turns out to be retrieving the linker timestamp from the <a href="https://web.archive.org/web/20120106051754/http://support.microsoft.com/kb/65122" rel="noreferrer">PE header</a> embedded in the executable file -- some C# code (by Joe Spivey) for that from the comments to Jeff's article:</p> <pre><code>public static DateTime GetLinkerTime(this Assembly assembly, TimeZoneInfo target = null) { var filePath = assembly.Location; const int c_PeHeaderOffset = 60; const int c_LinkerTimestampOffset = 8; var buffer = new byte[2048]; using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) stream.Read(buffer, 0, 2048); var offset = BitConverter.ToInt32(buffer, c_PeHeaderOffset); var secondsSince1970 = BitConverter.ToInt32(buffer, offset + c_LinkerTimestampOffset); var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); var linkTimeUtc = epoch.AddSeconds(secondsSince1970); var tz = target ?? TimeZoneInfo.Local; var localTime = TimeZoneInfo.ConvertTimeFromUtc(linkTimeUtc, tz); return localTime; } </code></pre> <p>Usage example:</p> <pre><code>var linkTimeLocal = Assembly.GetExecutingAssembly().GetLinkerTime(); </code></pre> <p>UPDATE: The method was working for .Net Core 1.0, but <strong>stopped working after .Net Core 1.1</strong> release(gives random years in 1900-2020 range) </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload