xxMask = 0 xC0 ; private const byte Variant1 0 xxValue = 0 x80 ; private const ushort VersionMask = 0 xF0 0 0 ; private const ushort Version7 Value = 0 x7 0 0 0 ; public static Guid CreateVersion7 () => CreateVersion7 (DateTimeOffset.UtcNow); public static Guid CreateVersion7 (DateTimeOffset timestamp) { // 普通にGUIDを作る Guid result = Guid.NewGuid(); // 先頭4 8bitをいい感じに埋める var unix_ts_ms = timestamp.ToUnixTimeMilliseconds(); // GUID layout is int _a; short _b; short _c, byte _d; Unsafe.As<Guid, int>(ref Unsafe.AsRef(ref result)) = (int)(unix_ts_ms >> 1 6 ); // _a Unsafe.Add(ref Unsafe.As<Guid, short>(ref Unsafe.AsRef(ref result)), 2 ) = (short)(unix_ts_ms); // _b ref var c = ref Unsafe.Add(ref Unsafe.As<Guid, short>(ref Unsafe.AsRef(ref result)), 3 ); c = (short)((c & ~VersionMask) | Version7 Value); ref var d = ref Unsafe.Add(ref Unsafe.As<Guid, byte>(ref Unsafe.AsRef(ref result)), 8); d = (byte)((d & ~Variant1 0 xxMask) | Variant1 0 xxValue); return result; } public static DateTimeOffset GetTimestamp(in Guid guid) { ref var p = ref Unsafe.As<Guid, byte>(ref Unsafe.AsRef(in guid)); var lower = Unsafe.ReadUnaligned<uint>(ref p); var upper = Unsafe.ReadUnaligned<ushort>(ref Unsafe.Add(ref p, 4 )); var time = (long)upper + (((long)lower) << 1 6 ); return DateTimeOffset.FromUnixTimeMilliseconds(time); } netstandard2.0向けにこういうの 作っちゃって、Guid v7に統一する のを選ぶかも Timestampの取得メソッドは標準 にはないので用意してもいいかも